about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-24 11:41:57 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-27 09:35:11 -0700
commit97b62ad034f12ea32bf5637a26b3830adfccd477 (patch)
treecaabf99f7557b45c167e9b1dcb4aa4a9b5a0ab16
parent8e0fce5ef1cda5482bbc190f51fd243ad30c9550 (diff)
downloadglibc-97b62ad034f12ea32bf5637a26b3830adfccd477.tar.gz
glibc-97b62ad034f12ea32bf5637a26b3830adfccd477.tar.xz
glibc-97b62ad034f12ea32bf5637a26b3830adfccd477.zip
Add i386 strrchr multiarch functions
-rw-r--r--sysdeps/i386/i686/multiarch/Makefile1
-rw-r--r--sysdeps/i386/i686/multiarch/strrchr.S57
-rw-r--r--sysdeps/i386/multiarch/Makefile3
-rw-r--r--sysdeps/i386/multiarch/ifunc-impl-list.c4
-rw-r--r--sysdeps/i386/multiarch/strrchr-i386.S14
-rw-r--r--sysdeps/i386/multiarch/strrchr-sse2-bsf.S (renamed from sysdeps/i386/i686/multiarch/strrchr-sse2-bsf.S)0
-rw-r--r--sysdeps/i386/multiarch/strrchr-sse2.S (renamed from sysdeps/i386/i686/multiarch/strrchr-sse2.S)0
-rw-r--r--sysdeps/i386/multiarch/strrchr.c55
8 files changed, 73 insertions, 61 deletions
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile
index 8f8e4509b8..2733c2a880 100644
--- a/sysdeps/i386/i686/multiarch/Makefile
+++ b/sysdeps/i386/i686/multiarch/Makefile
@@ -1,6 +1,5 @@
 ifeq ($(subdir),string)
 sysdep_routines += strlen-sse2 strlen-sse2-bsf \
-		   strrchr-sse2 strrchr-sse2-bsf \
 		   strnlen-sse2 strnlen-c
 ifeq (yes,$(config-cflags-sse4))
 sysdep_routines += strspn-c
diff --git a/sysdeps/i386/i686/multiarch/strrchr.S b/sysdeps/i386/i686/multiarch/strrchr.S
deleted file mode 100644
index 6aa3321907..0000000000
--- a/sysdeps/i386/i686/multiarch/strrchr.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Multiple versions of strrchr
-   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(strrchr)
-	.type	strrchr, @gnu_indirect_function
-	LOAD_GOT_AND_RTLD_GLOBAL_RO
-	LOAD_FUNC_GOT_EAX (__strrchr_ia32)
-	HAS_CPU_FEATURE (SSE2)
-	jz	2f
-	LOAD_FUNC_GOT_EAX (__strrchr_sse2_bsf)
-	HAS_ARCH_FEATURE (Slow_BSF)
-	jz	2f
-	LOAD_FUNC_GOT_EAX (__strrchr_sse2)
-2:	ret
-END(strrchr)
-
-# undef ENTRY
-# define ENTRY(name) \
-	.type __strrchr_ia32, @function; \
-	.globl __strrchr_ia32; \
-	.p2align 4; \
-	__strrchr_ia32: cfi_startproc; \
-	CALL_MCOUNT
-# undef END
-# define END(name) \
-	cfi_endproc; .size __strrchr_ia32, .-__strrchr_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_strrchr; __GI_strrchr = __strrchr_ia32
-#endif
-
-#include "../../strrchr.S"
diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile
index 23c1f8b0de..a4161b0f33 100644
--- a/sysdeps/i386/multiarch/Makefile
+++ b/sysdeps/i386/multiarch/Makefile
@@ -35,7 +35,8 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \
 		   strcat-i386 strcat-sse2 strcat-ssse3 \
 		   strncat-i386 strncat-sse2 strncat-ssse3 \
 		   strchr-i386 strchr-i586 strchr-sse2-bsf strchr-sse2 \
-		   strcspn-i386 strpbrk-i386
+		   strcspn-i386 strpbrk-i386 \
+		   strrchr-i386 strrchr-sse2-bsf strrchr-sse2
 ifeq (yes,$(config-cflags-sse4))
 sysdep_routines += varshift strcspn-sse4 strpbrk-sse4
 CFLAGS-varshift.c += -msse4
diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c
index 2fc97a31a4..f3bea9c9a5 100644
--- a/sysdeps/i386/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/multiarch/ifunc-impl-list.c
@@ -304,15 +304,15 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 			      __strpbrk_sse42)
 	      IFUNC_IMPL_ADD (array, i, strpbrk, 1, __strpbrk_i386))
 
-#if 0
   /* Support sysdeps/i386/i686/multiarch/strrchr.S.  */
   IFUNC_IMPL (i, name, strrchr,
 	      IFUNC_IMPL_ADD (array, i, strrchr, HAS_CPU_FEATURE (SSE2),
 			      __strrchr_sse2_bsf)
 	      IFUNC_IMPL_ADD (array, i, strrchr, HAS_CPU_FEATURE (SSE2),
 			      __strrchr_sse2)
-	      IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_ia32))
+	      IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_i386))
 
+#if 0
   /* Support sysdeps/i386/i686/multiarch/strspn.S.  */
   IFUNC_IMPL (i, name, strspn,
 	      IFUNC_IMPL_ADD (array, i, strspn, HAS_CPU_FEATURE (SSE4_2),
diff --git a/sysdeps/i386/multiarch/strrchr-i386.S b/sysdeps/i386/multiarch/strrchr-i386.S
new file mode 100644
index 0000000000..a7941e6f33
--- /dev/null
+++ b/sysdeps/i386/multiarch/strrchr-i386.S
@@ -0,0 +1,14 @@
+#define strrchr __strrchr_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/strrchr.S>
+
+#ifdef SHARED
+	.globl __GI_strrchr
+	.hidden __GI_strrchr
+	__GI_strrchr = __strrchr_i386
+#endif
diff --git a/sysdeps/i386/i686/multiarch/strrchr-sse2-bsf.S b/sysdeps/i386/multiarch/strrchr-sse2-bsf.S
index a3d42ddd4f..a3d42ddd4f 100644
--- a/sysdeps/i386/i686/multiarch/strrchr-sse2-bsf.S
+++ b/sysdeps/i386/multiarch/strrchr-sse2-bsf.S
diff --git a/sysdeps/i386/i686/multiarch/strrchr-sse2.S b/sysdeps/i386/multiarch/strrchr-sse2.S
index df36ba0a93..df36ba0a93 100644
--- a/sysdeps/i386/i686/multiarch/strrchr-sse2.S
+++ b/sysdeps/i386/multiarch/strrchr-sse2.S
diff --git a/sysdeps/i386/multiarch/strrchr.c b/sysdeps/i386/multiarch/strrchr.c
new file mode 100644
index 0000000000..995e00731c
--- /dev/null
+++ b/sysdeps/i386/multiarch/strrchr.c
@@ -0,0 +1,55 @@
+/* Multiple versions of strrchr
+   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)
+/* Redefine strrchr so that the compiler won't complain about the type
+   mismatch with the IFUNC selector in strong_alias, below.  */
+# undef strrchr
+# define strrchr __redirect_strrchr
+# include <string.h>
+# undef strrchr
+
+# include <init-arch.h>
+
+extern __typeof (__redirect_strrchr) __strrchr_i386 attribute_hidden;
+extern __typeof (__redirect_strrchr) __strrchr_sse2 attribute_hidden;
+extern __typeof (__redirect_strrchr) __strrchr_sse2_bsf attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+extern __typeof (__redirect_strrchr) strrchr;
+extern void *strrchr_ifunc (void) __asm__ ("strrchr");
+
+void *
+strrchr_ifunc (void)
+{
+  if (HAS_CPU_FEATURE (SSE2))
+    {
+      if (HAS_ARCH_FEATURE (Slow_BSF))
+	return __strrchr_sse2;
+      else
+	return __strrchr_sse2_bsf;
+    }
+
+  return __strrchr_i386;
+}
+__asm__ (".type strrchr, %gnu_indirect_function");
+weak_alias (strrchr, rindex)
+#endif