diff options
-rw-r--r-- | sysdeps/i386/i686/multiarch/Makefile | 2 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/memcmp-i386.S | 1 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/memcmp-i686.S | 7 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/memcmp.S | 62 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/memcmp.c | 1 | ||||
-rw-r--r-- | sysdeps/i386/i686/multiarch/rtld-memcmp.S | 19 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/Makefile | 3 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/ifunc-impl-list.c | 6 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/memcmp-i386.S | 12 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/memcmp-i686.S | 6 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/memcmp-sse4.S (renamed from sysdeps/i386/i686/multiarch/memcmp-sse4.S) | 0 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/memcmp-ssse3.S (renamed from sysdeps/i386/i686/multiarch/memcmp-ssse3.S) | 0 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/memcmp.c | 57 | ||||
-rw-r--r-- | sysdeps/i386/multiarch/rtld-memcmp.S | 19 |
14 files changed, 129 insertions, 66 deletions
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile index c088a39bea..ec128d7047 100644 --- a/sysdeps/i386/i686/multiarch/Makefile +++ b/sysdeps/i386/i686/multiarch/Makefile @@ -1,7 +1,7 @@ ifeq ($(subdir),string) sysdep_routines += strcmp-ssse3 \ strcmp-sse4 strncmp-c strncmp-ssse3 strncmp-sse4 \ - memcmp-ssse3 memcmp-sse4 varshift \ + varshift \ strlen-sse2 strlen-sse2-bsf strncpy-c strcpy-ssse3 \ strncpy-ssse3 stpcpy-ssse3 stpncpy-ssse3 strcpy-sse2 \ strncpy-sse2 stpcpy-sse2 stpncpy-sse2 strcat-ssse3 \ diff --git a/sysdeps/i386/i686/multiarch/memcmp-i386.S b/sysdeps/i386/i686/multiarch/memcmp-i386.S new file mode 100644 index 0000000000..9d841c9fd1 --- /dev/null +++ b/sysdeps/i386/i686/multiarch/memcmp-i386.S @@ -0,0 +1 @@ +/* Dummy file. */ diff --git a/sysdeps/i386/i686/multiarch/memcmp-i686.S b/sysdeps/i386/i686/multiarch/memcmp-i686.S new file mode 100644 index 0000000000..7aaf48b505 --- /dev/null +++ b/sysdeps/i386/i686/multiarch/memcmp-i686.S @@ -0,0 +1,7 @@ +#include <sysdeps/i386/multiarch/memcmp-i686.S> + +#ifdef SHARED + .globl __GI_memcmp + .hidden __GI_memcmp + __GI_memcmp = __memcmp_i686 +#endif diff --git a/sysdeps/i386/i686/multiarch/memcmp.S b/sysdeps/i386/i686/multiarch/memcmp.S deleted file mode 100644 index d4d7d2e91d..0000000000 --- a/sysdeps/i386/i686/multiarch/memcmp.S +++ /dev/null @@ -1,62 +0,0 @@ -/* Multiple versions of memcmp - All versions must be listed in ifunc-impl-list.c. - Copyright (C) 2010-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> - -/* Define multiple versions only for the definition in libc. */ -#if IS_IN (libc) - .text -ENTRY(memcmp) - .type memcmp, @gnu_indirect_function - LOAD_GOT_AND_RTLD_GLOBAL_RO - LOAD_FUNC_GOT_EAX (__memcmp_ia32) - HAS_CPU_FEATURE (SSSE3) - jz 2f - LOAD_FUNC_GOT_EAX (__memcmp_ssse3) - HAS_CPU_FEATURE (SSE4_2) - jz 2f - LOAD_FUNC_GOT_EAX (__memcmp_sse4_2) -2: ret -END(memcmp) - -# undef ENTRY -# define ENTRY(name) \ - .type __memcmp_ia32, @function; \ - .p2align 4; \ - .globl __memcmp_ia32; \ - .hidden __memcmp_ia32; \ - __memcmp_ia32: cfi_startproc; \ - CALL_MCOUNT -# undef END -# define END(name) \ - cfi_endproc; .size __memcmp_ia32, .-__memcmp_ia32 - -# ifdef SHARED -# 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_memcmp; __GI_memcmp = __memcmp_ia32 -# endif -#endif - -#include "../memcmp.S" diff --git a/sysdeps/i386/i686/multiarch/memcmp.c b/sysdeps/i386/i686/multiarch/memcmp.c new file mode 100644 index 0000000000..63103a072d --- /dev/null +++ b/sysdeps/i386/i686/multiarch/memcmp.c @@ -0,0 +1 @@ +#include <sysdeps/i386/multiarch/memcmp.c> diff --git a/sysdeps/i386/i686/multiarch/rtld-memcmp.S b/sysdeps/i386/i686/multiarch/rtld-memcmp.S new file mode 100644 index 0000000000..85ec290bd5 --- /dev/null +++ b/sysdeps/i386/i686/multiarch/rtld-memcmp.S @@ -0,0 +1,19 @@ +/* memcmp 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/i686/memcmp.S> diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile index 937cea9414..577bbb6c65 100644 --- a/sysdeps/i386/multiarch/Makefile +++ b/sysdeps/i386/multiarch/Makefile @@ -18,5 +18,6 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \ bzero-sse2 bzero-sse2-rep \ memset-i386 memset-i586 memset-i686 \ memset-sse2 memset-sse2-rep \ - memchr-sse2-bsf memchr-sse2 + memchr-sse2-bsf memchr-sse2 \ + memcmp-i386 memcmp-i686 memcmp-ssse3 memcmp-sse4 endif diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c index 420efb2874..e57134d340 100644 --- a/sysdeps/i386/multiarch/ifunc-impl-list.c +++ b/sysdeps/i386/multiarch/ifunc-impl-list.c @@ -71,15 +71,17 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __memchr_sse2) IFUNC_IMPL_ADD (array, i, memchr, 1, __memchr_i386)) -#if 0 /* Support sysdeps/i386/i686/multiarch/memcmp.S. */ IFUNC_IMPL (i, name, memcmp, IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSE4_2), __memcmp_sse4_2) IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSSE3), __memcmp_ssse3) - IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ia32)) + IFUNC_IMPL_ADD (array, i, memcmp, HAS_I686, __memcmp_i686) +#if MINIMUM_ISA < 686 + IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_i386) #endif + ) /* Support sysdeps/i386/i686/multiarch/memmove_chk.S. */ IFUNC_IMPL (i, name, __memmove_chk, diff --git a/sysdeps/i386/multiarch/memcmp-i386.S b/sysdeps/i386/multiarch/memcmp-i386.S new file mode 100644 index 0000000000..18e7424966 --- /dev/null +++ b/sysdeps/i386/multiarch/memcmp-i386.S @@ -0,0 +1,12 @@ +#define memcmp __memcmp_i386 +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(name) +#undef weak_alias +#define weak_alias(name, aliasname) +#include <sysdeps/i386/memcmp.S> + +#ifdef SHARED + .globl __GI_memcmp + .hidden __GI_memcmp + __GI_memcmp = __memcmp_i386 +#endif diff --git a/sysdeps/i386/multiarch/memcmp-i686.S b/sysdeps/i386/multiarch/memcmp-i686.S new file mode 100644 index 0000000000..32d1a4da6c --- /dev/null +++ b/sysdeps/i386/multiarch/memcmp-i686.S @@ -0,0 +1,6 @@ +#define memcmp __memcmp_i686 +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(name) +#undef weak_alias +#define weak_alias(name, aliasname) +#include <sysdeps/i386/i686/memcmp.S> diff --git a/sysdeps/i386/i686/multiarch/memcmp-sse4.S b/sysdeps/i386/multiarch/memcmp-sse4.S index b3756f4a00..b3756f4a00 100644 --- a/sysdeps/i386/i686/multiarch/memcmp-sse4.S +++ b/sysdeps/i386/multiarch/memcmp-sse4.S diff --git a/sysdeps/i386/i686/multiarch/memcmp-ssse3.S b/sysdeps/i386/multiarch/memcmp-ssse3.S index ea2a25b216..ea2a25b216 100644 --- a/sysdeps/i386/i686/multiarch/memcmp-ssse3.S +++ b/sysdeps/i386/multiarch/memcmp-ssse3.S diff --git a/sysdeps/i386/multiarch/memcmp.c b/sysdeps/i386/multiarch/memcmp.c new file mode 100644 index 0000000000..36ca7da67e --- /dev/null +++ b/sysdeps/i386/multiarch/memcmp.c @@ -0,0 +1,57 @@ +/* Multiple versions of memcmp. + 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 lib. */ +#if IS_IN (libc) +/* Redefine memcmp so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef memcmp +# define memcmp __redirect_memcmp +# include <string.h> +# undef memcmp + +# include <init-arch.h> + +extern __typeof (__redirect_memcmp) __memcmp_i386 attribute_hidden; +extern __typeof (__redirect_memcmp) __memcmp_i686 attribute_hidden; +extern __typeof (__redirect_memcmp) __memcmp_ssse3 attribute_hidden; +extern __typeof (__redirect_memcmp) __memcmp_sse4_2 attribute_hidden; + +/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle + ifunc symbol properly. */ +extern __typeof (__redirect_memcmp) memcmp; +extern void *memcmp_ifunc (void) __asm__ ("memcmp"); + +void * +memcmp_ifunc (void) +{ + if (HAS_CPU_FEATURE (SSE4_2)) + return __memcmp_sse4_2; + else if (HAS_CPU_FEATURE (SSSE3)) + return __memcmp_ssse3; + + if (USE_I686) + return __memcmp_i686; + else + return __memcmp_i386; +} +__asm__ (".type memcmp, %gnu_indirect_function"); + +weak_alias (memcmp, bcmp) +#endif diff --git a/sysdeps/i386/multiarch/rtld-memcmp.S b/sysdeps/i386/multiarch/rtld-memcmp.S new file mode 100644 index 0000000000..d3a07fe73a --- /dev/null +++ b/sysdeps/i386/multiarch/rtld-memcmp.S @@ -0,0 +1,19 @@ +/* memcmp 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/memcmp.S> |