about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-23 12:47:24 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-27 09:35:11 -0700
commiteafb1c2a37d1886de47e7fa757f869c4daf5a491 (patch)
treeef42196fb03056c7e69ef6fccb9fbb93c3bec3da
parentd5496eb9a14df0fe463c211f5fe05cc73e8e770c (diff)
downloadglibc-eafb1c2a37d1886de47e7fa757f869c4daf5a491.tar.gz
glibc-eafb1c2a37d1886de47e7fa757f869c4daf5a491.tar.xz
glibc-eafb1c2a37d1886de47e7fa757f869c4daf5a491.zip
Add i386 strchr multiarch functions
-rw-r--r--sysdeps/i386/i586/multiarch/rtld-strchr.S19
-rw-r--r--sysdeps/i386/i586/multiarch/strchr-i386.S8
-rw-r--r--sysdeps/i386/i586/multiarch/strchr-i586.S7
-rw-r--r--sysdeps/i386/i586/multiarch/strchr.c1
-rw-r--r--sysdeps/i386/i686/multiarch/Makefile2
-rw-r--r--sysdeps/i386/i686/multiarch/strchr-i586.S1
-rw-r--r--sysdeps/i386/i686/multiarch/strchr.S57
-rw-r--r--sysdeps/i386/multiarch/Makefile3
-rw-r--r--sysdeps/i386/multiarch/ifunc-impl-list.c4
-rw-r--r--sysdeps/i386/multiarch/rtld-strchr.S19
-rw-r--r--sysdeps/i386/multiarch/strchr-i386.S7
-rw-r--r--sysdeps/i386/multiarch/strchr-i586.S8
-rw-r--r--sysdeps/i386/multiarch/strchr-sse2-bsf.S (renamed from sysdeps/i386/i686/multiarch/strchr-sse2-bsf.S)0
-rw-r--r--sysdeps/i386/multiarch/strchr-sse2.S (renamed from sysdeps/i386/i686/multiarch/strchr-sse2.S)0
-rw-r--r--sysdeps/i386/multiarch/strchr.c60
15 files changed, 134 insertions, 62 deletions
diff --git a/sysdeps/i386/i586/multiarch/rtld-strchr.S b/sysdeps/i386/i586/multiarch/rtld-strchr.S
new file mode 100644
index 0000000000..a26da1cac9
--- /dev/null
+++ b/sysdeps/i386/i586/multiarch/rtld-strchr.S
@@ -0,0 +1,19 @@
+/* strchr for ld.so
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdeps/i386/i586/strchr.S>
diff --git a/sysdeps/i386/i586/multiarch/strchr-i386.S b/sysdeps/i386/i586/multiarch/strchr-i386.S
new file mode 100644
index 0000000000..74850fa4d5
--- /dev/null
+++ b/sysdeps/i386/i586/multiarch/strchr-i386.S
@@ -0,0 +1,8 @@
+#define strchr __strchr_i386
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#undef libc_hidden_def
+#define libc_hidden_def(name)
+#undef weak_alias
+#define weak_alias(name, aliasname)
+#include <sysdeps/i386/strchr.S>
diff --git a/sysdeps/i386/i586/multiarch/strchr-i586.S b/sysdeps/i386/i586/multiarch/strchr-i586.S
new file mode 100644
index 0000000000..48e71aa74e
--- /dev/null
+++ b/sysdeps/i386/i586/multiarch/strchr-i586.S
@@ -0,0 +1,7 @@
+#include <sysdeps/i386/multiarch/strchr-i586.S>
+
+#ifdef SHARED
+	.globl __GI_strchr
+	.hidden __GI_strchr
+	__GI_strchr = __strchr_i586
+#endif
diff --git a/sysdeps/i386/i586/multiarch/strchr.c b/sysdeps/i386/i586/multiarch/strchr.c
new file mode 100644
index 0000000000..61c2f14b86
--- /dev/null
+++ b/sysdeps/i386/i586/multiarch/strchr.c
@@ -0,0 +1 @@
+#include <sysdeps/i386/multiarch/strchr.c>
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile
index 830c77d951..788dccb2c9 100644
--- a/sysdeps/i386/i686/multiarch/Makefile
+++ b/sysdeps/i386/i686/multiarch/Makefile
@@ -1,7 +1,7 @@
 ifeq ($(subdir),string)
 sysdep_routines += varshift \
 		   strlen-sse2 strlen-sse2-bsf \
-		   strchr-sse2 strrchr-sse2 strchr-sse2-bsf strrchr-sse2-bsf \
+		   strrchr-sse2 strrchr-sse2-bsf \
 		   strnlen-sse2 strnlen-c
 ifeq (yes,$(config-cflags-sse4))
 sysdep_routines += strcspn-c strpbrk-c strspn-c
diff --git a/sysdeps/i386/i686/multiarch/strchr-i586.S b/sysdeps/i386/i686/multiarch/strchr-i586.S
new file mode 100644
index 0000000000..9d841c9fd1
--- /dev/null
+++ b/sysdeps/i386/i686/multiarch/strchr-i586.S
@@ -0,0 +1 @@
+/* Dummy file.  */
diff --git a/sysdeps/i386/i686/multiarch/strchr.S b/sysdeps/i386/i686/multiarch/strchr.S
deleted file mode 100644
index 6b4656582a..0000000000
--- a/sysdeps/i386/i686/multiarch/strchr.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Multiple versions of strchr
-   All versions must be listed in ifunc-impl-list.c.
-   Copyright (C) 2011-2015 Free Software Foundation, Inc.
-   Contributed by Intel Corporation.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <init-arch.h>
-
-#if IS_IN (libc)
-	.text
-ENTRY(strchr)
-	.type	strchr, @gnu_indirect_function
-	LOAD_GOT_AND_RTLD_GLOBAL_RO
-	LOAD_FUNC_GOT_EAX (__strchr_ia32)
-	HAS_CPU_FEATURE (SSE2)
-	jz	2f
-	LOAD_FUNC_GOT_EAX (__strchr_sse2_bsf)
-	HAS_ARCH_FEATURE (Slow_BSF)
-	jz	2f
-	LOAD_FUNC_GOT_EAX (__strchr_sse2)
-2:	ret
-END(strchr)
-
-# undef ENTRY
-# define ENTRY(name) \
-	.type __strchr_ia32, @function; \
-	.globl __strchr_ia32; \
-	.p2align 4; \
-	__strchr_ia32: cfi_startproc; \
-	CALL_MCOUNT
-# undef END
-# define END(name) \
-	cfi_endproc; .size __strchr_ia32, .-__strchr_ia32
-# undef libc_hidden_builtin_def
-/* IFUNC doesn't work with the hidden functions in shared library since
-   they will be called without setting up EBX needed for PLT which is
-   used by IFUNC.  */
-# define libc_hidden_builtin_def(name) \
-	.globl __GI_strchr; __GI_strchr = __strchr_ia32
-#endif
-
-#include "../../i586/strchr.S"
diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile
index 87d36a42ca..369a56665c 100644
--- a/sysdeps/i386/multiarch/Makefile
+++ b/sysdeps/i386/multiarch/Makefile
@@ -33,7 +33,8 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \
 		   strncase_l-ssse3 \
 		   strncmp-i386 strncmp-ssse3 strncmp-sse4 \
 		   strcat-i386 strcat-sse2 strcat-ssse3 \
-		   strncat-i386 strncat-sse2 strncat-ssse3
+		   strncat-i386 strncat-sse2 strncat-ssse3 \
+		   strchr-i386 strchr-i586 strchr-sse2-bsf strchr-sse2
 endif
 
 ifeq (mathyes,$(subdir)$(config-cflags-avx))
diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c
index 05b9bcd622..b938329a47 100644
--- a/sysdeps/i386/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/multiarch/ifunc-impl-list.c
@@ -214,15 +214,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			      __strcat_sse2)
 	      IFUNC_IMPL_ADD (array, i, strcat, 1, __strcat_i386))
 
-#if 0
   /* Support sysdeps/i386/i686/multiarch/strchr.S.  */
   IFUNC_IMPL (i, name, strchr,
 	      IFUNC_IMPL_ADD (array, i, strchr, HAS_CPU_FEATURE (SSE2),
 			      __strchr_sse2_bsf)
 	      IFUNC_IMPL_ADD (array, i, strchr, HAS_CPU_FEATURE (SSE2),
 			      __strchr_sse2)
-	      IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_ia32))
-#endif
+	      IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_i386))
 
   /* Support sysdeps/i386/i686/multiarch/strcmp.S.  */
   IFUNC_IMPL (i, name, strcmp,
diff --git a/sysdeps/i386/multiarch/rtld-strchr.S b/sysdeps/i386/multiarch/rtld-strchr.S
new file mode 100644
index 0000000000..a032fdb733
--- /dev/null
+++ b/sysdeps/i386/multiarch/rtld-strchr.S
@@ -0,0 +1,19 @@
+/* strchr for ld.so
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdeps/i386/strchr.S>
diff --git a/sysdeps/i386/multiarch/strchr-i386.S b/sysdeps/i386/multiarch/strchr-i386.S
new file mode 100644
index 0000000000..aff0f7ae20
--- /dev/null
+++ b/sysdeps/i386/multiarch/strchr-i386.S
@@ -0,0 +1,7 @@
+#include <sysdeps/i386/i586/multiarch/strchr-i386.S>
+
+#ifdef SHARED
+	.globl __GI_strchr
+	.hidden __GI_strchr
+	__GI_strchr = __strchr_i386
+#endif
diff --git a/sysdeps/i386/multiarch/strchr-i586.S b/sysdeps/i386/multiarch/strchr-i586.S
new file mode 100644
index 0000000000..b4327f4f89
--- /dev/null
+++ b/sysdeps/i386/multiarch/strchr-i586.S
@@ -0,0 +1,8 @@
+#define strchr __strchr_i586
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+#undef libc_hidden_def
+#define libc_hidden_def(name)
+#undef weak_alias
+#define weak_alias(name, aliasname)
+#include <sysdeps/i386/i586/strchr.S>
diff --git a/sysdeps/i386/i686/multiarch/strchr-sse2-bsf.S b/sysdeps/i386/multiarch/strchr-sse2-bsf.S
index ba2723bb51..ba2723bb51 100644
--- a/sysdeps/i386/i686/multiarch/strchr-sse2-bsf.S
+++ b/sysdeps/i386/multiarch/strchr-sse2-bsf.S
diff --git a/sysdeps/i386/i686/multiarch/strchr-sse2.S b/sysdeps/i386/multiarch/strchr-sse2.S
index 4f387eaeea..4f387eaeea 100644
--- a/sysdeps/i386/i686/multiarch/strchr-sse2.S
+++ b/sysdeps/i386/multiarch/strchr-sse2.S
diff --git a/sysdeps/i386/multiarch/strchr.c b/sysdeps/i386/multiarch/strchr.c
new file mode 100644
index 0000000000..015b51c129
--- /dev/null
+++ b/sysdeps/i386/multiarch/strchr.c
@@ -0,0 +1,60 @@
+/* Multiple versions of strchr
+   All versions must be listed in ifunc-impl-list.c.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Define multiple versions only for the definition in libc.  */
+#if IS_IN (libc)
+# define _HAVE_STRING_ARCH_strchr
+/* Redefine strchr so that the compiler won't complain about the type
+   mismatch with the IFUNC selector in strong_alias, below.  */
+# undef strchr
+# define strchr __redirect_strchr
+# include <string.h>
+# undef strchr
+
+# include <init-arch.h>
+
+extern __typeof (__redirect_strchr) __strchr_i386 attribute_hidden;
+extern __typeof (__redirect_strchr) __strchr_i586 attribute_hidden;
+extern __typeof (__redirect_strchr) __strchr_sse2 attribute_hidden;
+extern __typeof (__redirect_strchr) __strchr_sse2_bsf attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_strchr) strchr;
+extern void *strchr_ifunc (void) __asm__ ("strchr");
+
+void *
+strchr_ifunc (void)
+{
+  if (HAS_CPU_FEATURE (SSE2))
+    {
+      if (HAS_ARCH_FEATURE (Slow_BSF))
+	return __strchr_sse2;
+      else
+	return __strchr_sse2_bsf;
+    }
+
+  if (USE_I586)
+    return __strchr_i586;
+  else
+    return __strchr_i386;
+}
+__asm__ (".type strchr, %gnu_indirect_function");
+weak_alias (strchr, index)
+#endif