|
|
51f0aa |
This patch provides a compatibility kludge for legacy applications
|
|
|
51f0aa |
which do not provide proper stack alignment. It cannot be upstreamed.
|
|
|
51f0aa |
|
|
|
51f0aa |
The kludge is active for both i386 and x86-64, but it is actually only
|
|
|
51f0aa |
needed on i386.
|
|
|
51f0aa |
|
|
|
51f0aa |
In Fedora, the same effect was achieved by disabling multi-arch
|
|
|
51f0aa |
altogether:
|
|
|
51f0aa |
|
|
|
51f0aa |
https://bugzilla.redhat.com/show_bug.cgi?id=1471427
|
|
|
51f0aa |
|
|
|
51f0aa |
Further discussion is on this internal bug:
|
|
|
51f0aa |
|
|
|
51f0aa |
https://bugzilla.redhat.com/show_bug.cgi?id=1478332
|
|
|
51f0aa |
|
|
|
51f0aa |
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/ifunc-impl-list.c 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/ifunc-impl-list.c 2015-04-20 09:04:11.826569951 -0600
|
|
|
ce426f |
@@ -212,6 +212,8 @@
|
|
|
ce426f |
|
|
|
ce426f |
/* Support sysdeps/x86_64/multiarch/strstr-c.c. */
|
|
|
ce426f |
IFUNC_IMPL (i, name, strstr,
|
|
|
ce426f |
+ IFUNC_IMPL_ADD (array, i, strstr, use_unaligned_strstr (),
|
|
|
ce426f |
+ __strstr_sse2_unaligned)
|
|
|
ce426f |
IFUNC_IMPL_ADD (array, i, strstr, HAS_SSE4_2, __strstr_sse42)
|
|
|
ce426f |
IFUNC_IMPL_ADD (array, i, strstr, 1, __strstr_sse2))
|
|
|
ce426f |
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/init-arch.h 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/init-arch.h 2015-04-20 12:15:17.984742925 -0600
|
|
|
ce426f |
@@ -63,6 +63,34 @@
|
|
|
ce426f |
#else /* __ASSEMBLER__ */
|
|
|
ce426f |
|
|
|
ce426f |
# include <sys/param.h>
|
|
|
ce426f |
+# include <sys/types.h>
|
|
|
ce426f |
+# include <sysdep.h>
|
|
|
ce426f |
+# include <stdbool.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* Ugly hack to make it possible to select a strstr and strcasestr
|
|
|
ce426f |
+ implementation that avoids using the stack for 16-byte aligned
|
|
|
ce426f |
+ SSE temporaries. Doing so makes it possible to call the functions
|
|
|
ce426f |
+ with a stack that's not 16-byte aligned as can happen, for example,
|
|
|
ce426f |
+ as a result of compiling the functions' callers with the GCC
|
|
|
ce426f |
+ -mpreferred-stack-boubdary=2 or =3 option, or with the ICC
|
|
|
ce426f |
+ -falign-stack=assume-4-byte option. See rhbz 1150282 for details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The ifunc selector uses the unaligned version by default if this
|
|
|
ce426f |
+ file exists and is accessible. */
|
|
|
ce426f |
+# define ENABLE_STRSTR_UNALIGNED_PATHNAME \
|
|
|
ce426f |
+ "/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned"
|
|
|
ce426f |
+
|
|
|
ce426f |
+static bool __attribute__ ((unused))
|
|
|
ce426f |
+use_unaligned_strstr (void)
|
|
|
ce426f |
+{
|
|
|
ce426f |
+ struct stat unaligned_strstr_etc_sysconfig_file;
|
|
|
ce426f |
+
|
|
|
ce426f |
+ /* TLS may not have been set up yet, so avoid using stat since it tries to
|
|
|
ce426f |
+ set errno. */
|
|
|
ce426f |
+ return INTERNAL_SYSCALL (stat, , 2,
|
|
|
ce426f |
+ ENABLE_STRSTR_UNALIGNED_PATHNAME,
|
|
|
ce426f |
+ &unaligned_strstr_etc_sysconfig_file) == 0;
|
|
|
ce426f |
+}
|
|
|
ce426f |
|
|
|
ce426f |
enum
|
|
|
ce426f |
{
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/Makefile 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/Makefile 2015-04-20 09:04:11.854569626 -0600
|
|
|
ce426f |
@@ -17,7 +17,7 @@
|
|
|
ce426f |
strcat-sse2-unaligned strncat-sse2-unaligned \
|
|
|
ce426f |
strcat-ssse3 strncat-ssse3 strlen-sse2-pminub \
|
|
|
ce426f |
strnlen-sse2-no-bsf strrchr-sse2-no-bsf strchr-sse2-no-bsf \
|
|
|
ce426f |
- memcmp-ssse3
|
|
|
ce426f |
+ memcmp-ssse3 strstr-sse2-unaligned
|
|
|
ce426f |
ifeq (yes,$(config-cflags-sse4))
|
|
|
ce426f |
sysdep_routines += strcspn-c strpbrk-c strspn-c strstr-c strcasestr-c varshift
|
|
|
ce426f |
CFLAGS-varshift.c += -msse4
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strcasestr-c.c 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strcasestr-c.c 2015-04-20 09:04:11.861569545 -0600
|
|
|
ce426f |
@@ -12,7 +12,8 @@
|
|
|
ce426f |
|
|
|
ce426f |
#if 1
|
|
|
ce426f |
libc_ifunc (__strcasestr,
|
|
|
ce426f |
- HAS_SSE4_2 ? __strcasestr_sse42 : __strcasestr_sse2);
|
|
|
ce426f |
+ HAS_SSE4_2 && !use_unaligned_strstr () ? __strcasestr_sse42 :
|
|
|
ce426f |
+ __strcasestr_sse2);
|
|
|
ce426f |
#else
|
|
|
ce426f |
libc_ifunc (__strcasestr,
|
|
|
ce426f |
0 ? __strcasestr_sse42 : __strcasestr_sse2);
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-c.c 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-c.c 2015-04-20 09:04:11.866569487 -0600
|
|
|
ce426f |
@@ -34,6 +34,7 @@
|
|
|
ce426f |
#include "string/strstr.c"
|
|
|
ce426f |
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __strstr_sse42 attribute_hidden;
|
|
|
ce426f |
+extern __typeof (__redirect_strstr) __strstr_sse2_unaligned attribute_hidden;
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __strstr_sse2 attribute_hidden;
|
|
|
ce426f |
|
|
|
ce426f |
#include "init-arch.h"
|
|
|
ce426f |
@@ -41,7 +42,9 @@
|
|
|
ce426f |
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
|
|
|
ce426f |
ifunc symbol properly. */
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __libc_strstr;
|
|
|
ce426f |
-libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_sse2)
|
|
|
ce426f |
+libc_ifunc (__libc_strstr, HAS_SSE4_2 ? (use_unaligned_strstr () ?
|
|
|
ce426f |
+ __strstr_sse2_unaligned :
|
|
|
ce426f |
+ __strstr_sse42) : __strstr_sse2)
|
|
|
ce426f |
|
|
|
ce426f |
#undef strstr
|
|
|
ce426f |
strong_alias (__libc_strstr, strstr)
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S 1969-12-31 17:00:00.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S 2015-04-20 09:04:11.866569487 -0600
|
|
|
ce426f |
@@ -0,0 +1,374 @@
|
|
|
ce426f |
+/* strstr with unaligned loads
|
|
|
ce426f |
+ Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+#include <sysdep.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+ENTRY(__strstr_sse2_unaligned)
|
|
|
ce426f |
+ movzbl (%rsi), %eax
|
|
|
ce426f |
+ testb %al, %al
|
|
|
ce426f |
+ je L(empty)
|
|
|
ce426f |
+ movzbl 1(%rsi), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ je L(strchr)
|
|
|
ce426f |
+ movd %eax, %xmm1
|
|
|
ce426f |
+ movd %edx, %xmm2
|
|
|
ce426f |
+ movq %rdi, %rax
|
|
|
ce426f |
+ andl $4095, %eax
|
|
|
ce426f |
+ punpcklbw %xmm1, %xmm1
|
|
|
ce426f |
+ cmpq $4031, %rax
|
|
|
ce426f |
+ punpcklbw %xmm2, %xmm2
|
|
|
ce426f |
+ punpcklwd %xmm1, %xmm1
|
|
|
ce426f |
+ punpcklwd %xmm2, %xmm2
|
|
|
ce426f |
+ pshufd $0, %xmm1, %xmm1
|
|
|
ce426f |
+ pshufd $0, %xmm2, %xmm2
|
|
|
ce426f |
+ ja L(cross_page)
|
|
|
ce426f |
+ movdqu (%rdi), %xmm3
|
|
|
ce426f |
+ pxor %xmm5, %xmm5
|
|
|
ce426f |
+ movdqu 1(%rdi), %xmm4
|
|
|
ce426f |
+ movdqa %xmm3, %xmm6
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm4
|
|
|
ce426f |
+ movdqu 16(%rdi), %xmm0
|
|
|
ce426f |
+ pcmpeqb %xmm5, %xmm6
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqa %xmm3, %xmm4
|
|
|
ce426f |
+ movdqu 17(%rdi), %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm0, %xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ por %xmm6, %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm0
|
|
|
ce426f |
+ pminub %xmm3, %xmm0
|
|
|
ce426f |
+ por %xmm5, %xmm0
|
|
|
ce426f |
+ pmovmskb %xmm4, %r8d
|
|
|
ce426f |
+ pmovmskb %xmm0, %eax
|
|
|
ce426f |
+ salq $16, %rax
|
|
|
ce426f |
+ orq %rax, %r8
|
|
|
ce426f |
+ je L(next_32_bytes)
|
|
|
ce426f |
+L(next_pair_index):
|
|
|
ce426f |
+ bsf %r8, %rax
|
|
|
ce426f |
+ addq %rdi, %rax
|
|
|
ce426f |
+ cmpb $0, (%rax)
|
|
|
ce426f |
+ je L(zero1)
|
|
|
ce426f |
+ movzbl 2(%rsi), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ je L(found1)
|
|
|
ce426f |
+ cmpb 2(%rax), %dl
|
|
|
ce426f |
+ jne L(next_pair)
|
|
|
ce426f |
+ xorl %edx, %edx
|
|
|
ce426f |
+ jmp L(pair_loop_start)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(strchr):
|
|
|
ce426f |
+ movzbl %al, %esi
|
|
|
ce426f |
+ jmp __strchr_sse2
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(pair_loop):
|
|
|
ce426f |
+ addq $1, %rdx
|
|
|
ce426f |
+ cmpb 2(%rax,%rdx), %cl
|
|
|
ce426f |
+ jne L(next_pair)
|
|
|
ce426f |
+L(pair_loop_start):
|
|
|
ce426f |
+ movzbl 3(%rsi,%rdx), %ecx
|
|
|
ce426f |
+ testb %cl, %cl
|
|
|
ce426f |
+ jne L(pair_loop)
|
|
|
ce426f |
+L(found1):
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+L(zero1):
|
|
|
ce426f |
+ xorl %eax, %eax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(next_pair):
|
|
|
ce426f |
+ leaq -1(%r8), %rax
|
|
|
ce426f |
+ andq %rax, %r8
|
|
|
ce426f |
+ jne L(next_pair_index)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(next_32_bytes):
|
|
|
ce426f |
+ movdqu 32(%rdi), %xmm3
|
|
|
ce426f |
+ pxor %xmm5, %xmm5
|
|
|
ce426f |
+ movdqu 33(%rdi), %xmm4
|
|
|
ce426f |
+ movdqa %xmm3, %xmm6
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm4
|
|
|
ce426f |
+ movdqu 48(%rdi), %xmm0
|
|
|
ce426f |
+ pcmpeqb %xmm5, %xmm6
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqa %xmm3, %xmm4
|
|
|
ce426f |
+ movdqu 49(%rdi), %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm0, %xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ por %xmm6, %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm0
|
|
|
ce426f |
+ pminub %xmm3, %xmm0
|
|
|
ce426f |
+ por %xmm5, %xmm0
|
|
|
ce426f |
+ pmovmskb %xmm4, %eax
|
|
|
ce426f |
+ salq $32, %rax
|
|
|
ce426f |
+ pmovmskb %xmm0, %r8d
|
|
|
ce426f |
+ salq $48, %r8
|
|
|
ce426f |
+ orq %rax, %r8
|
|
|
ce426f |
+ je L(loop_header)
|
|
|
ce426f |
+L(next_pair2_index):
|
|
|
ce426f |
+ bsfq %r8, %rax
|
|
|
ce426f |
+ addq %rdi, %rax
|
|
|
ce426f |
+ cmpb $0, (%rax)
|
|
|
ce426f |
+ je L(zero2)
|
|
|
ce426f |
+ movzbl 2(%rsi), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ je L(found2)
|
|
|
ce426f |
+ cmpb 2(%rax), %dl
|
|
|
ce426f |
+ jne L(next_pair2)
|
|
|
ce426f |
+ xorl %edx, %edx
|
|
|
ce426f |
+ jmp L(pair_loop2_start)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(pair_loop2):
|
|
|
ce426f |
+ addq $1, %rdx
|
|
|
ce426f |
+ cmpb 2(%rax,%rdx), %cl
|
|
|
ce426f |
+ jne L(next_pair2)
|
|
|
ce426f |
+L(pair_loop2_start):
|
|
|
ce426f |
+ movzbl 3(%rsi,%rdx), %ecx
|
|
|
ce426f |
+ testb %cl, %cl
|
|
|
ce426f |
+ jne L(pair_loop2)
|
|
|
ce426f |
+L(found2):
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+ L(zero2):
|
|
|
ce426f |
+ xorl %eax, %eax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+L(empty):
|
|
|
ce426f |
+ mov %rdi, %rax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(next_pair2):
|
|
|
ce426f |
+ leaq -1(%r8), %rax
|
|
|
ce426f |
+ andq %rax, %r8
|
|
|
ce426f |
+ jne L(next_pair2_index)
|
|
|
ce426f |
+L(loop_header):
|
|
|
ce426f |
+ movq $-512, %r11
|
|
|
ce426f |
+ movq %rdi, %r9
|
|
|
ce426f |
+
|
|
|
ce426f |
+ pxor %xmm7, %xmm7
|
|
|
ce426f |
+ andq $-64, %rdi
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(loop):
|
|
|
ce426f |
+ movdqa 64(%rdi), %xmm3
|
|
|
ce426f |
+ movdqu 63(%rdi), %xmm6
|
|
|
ce426f |
+ movdqa %xmm3, %xmm0
|
|
|
ce426f |
+ pxor %xmm2, %xmm3
|
|
|
ce426f |
+ pxor %xmm1, %xmm6
|
|
|
ce426f |
+ movdqa 80(%rdi), %xmm10
|
|
|
ce426f |
+ por %xmm3, %xmm6
|
|
|
ce426f |
+ pminub %xmm10, %xmm0
|
|
|
ce426f |
+ movdqu 79(%rdi), %xmm3
|
|
|
ce426f |
+ pxor %xmm2, %xmm10
|
|
|
ce426f |
+ pxor %xmm1, %xmm3
|
|
|
ce426f |
+ movdqa 96(%rdi), %xmm9
|
|
|
ce426f |
+ por %xmm10, %xmm3
|
|
|
ce426f |
+ pminub %xmm9, %xmm0
|
|
|
ce426f |
+ pxor %xmm2, %xmm9
|
|
|
ce426f |
+ movdqa 112(%rdi), %xmm8
|
|
|
ce426f |
+ addq $64, %rdi
|
|
|
ce426f |
+ pminub %xmm6, %xmm3
|
|
|
ce426f |
+ movdqu 31(%rdi), %xmm4
|
|
|
ce426f |
+ pminub %xmm8, %xmm0
|
|
|
ce426f |
+ pxor %xmm2, %xmm8
|
|
|
ce426f |
+ pxor %xmm1, %xmm4
|
|
|
ce426f |
+ por %xmm9, %xmm4
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqu 47(%rdi), %xmm5
|
|
|
ce426f |
+ pxor %xmm1, %xmm5
|
|
|
ce426f |
+ por %xmm8, %xmm5
|
|
|
ce426f |
+ pminub %xmm5, %xmm3
|
|
|
ce426f |
+ pminub %xmm3, %xmm0
|
|
|
ce426f |
+ pcmpeqb %xmm7, %xmm0
|
|
|
ce426f |
+ pmovmskb %xmm0, %eax
|
|
|
ce426f |
+ testl %eax, %eax
|
|
|
ce426f |
+ je L(loop)
|
|
|
ce426f |
+ pminub (%rdi), %xmm6
|
|
|
ce426f |
+ pminub 32(%rdi),%xmm4
|
|
|
ce426f |
+ pminub 48(%rdi),%xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm7, %xmm6
|
|
|
ce426f |
+ pcmpeqb %xmm7, %xmm5
|
|
|
ce426f |
+ pmovmskb %xmm6, %edx
|
|
|
ce426f |
+ movdqa 16(%rdi), %xmm8
|
|
|
ce426f |
+ pcmpeqb %xmm7, %xmm4
|
|
|
ce426f |
+ movdqu 15(%rdi), %xmm0
|
|
|
ce426f |
+ pmovmskb %xmm5, %r8d
|
|
|
ce426f |
+ movdqa %xmm8, %xmm3
|
|
|
ce426f |
+ pmovmskb %xmm4, %ecx
|
|
|
ce426f |
+ pcmpeqb %xmm1,%xmm0
|
|
|
ce426f |
+ pcmpeqb %xmm2,%xmm3
|
|
|
ce426f |
+ salq $32, %rcx
|
|
|
ce426f |
+ pcmpeqb %xmm7,%xmm8
|
|
|
ce426f |
+ salq $48, %r8
|
|
|
ce426f |
+ pminub %xmm0,%xmm3
|
|
|
ce426f |
+ orq %rcx, %rdx
|
|
|
ce426f |
+ por %xmm3,%xmm8
|
|
|
ce426f |
+ orq %rdx, %r8
|
|
|
ce426f |
+ pmovmskb %xmm8, %eax
|
|
|
ce426f |
+ salq $16, %rax
|
|
|
ce426f |
+ orq %rax, %r8
|
|
|
ce426f |
+ je L(loop)
|
|
|
ce426f |
+L(next_pair_index3):
|
|
|
ce426f |
+ bsfq %r8, %rcx
|
|
|
ce426f |
+ addq %rdi, %rcx
|
|
|
ce426f |
+ cmpb $0, (%rcx)
|
|
|
ce426f |
+ je L(zero)
|
|
|
ce426f |
+ xorl %eax, %eax
|
|
|
ce426f |
+ movzbl 2(%rsi), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ je L(success3)
|
|
|
ce426f |
+ cmpb 1(%rcx), %dl
|
|
|
ce426f |
+ jne L(next_pair3)
|
|
|
ce426f |
+ jmp L(pair_loop_start3)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(pair_loop3):
|
|
|
ce426f |
+ addq $1, %rax
|
|
|
ce426f |
+ cmpb 1(%rcx,%rax), %dl
|
|
|
ce426f |
+ jne L(next_pair3)
|
|
|
ce426f |
+L(pair_loop_start3):
|
|
|
ce426f |
+ movzbl 3(%rsi,%rax), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ jne L(pair_loop3)
|
|
|
ce426f |
+L(success3):
|
|
|
ce426f |
+ lea -1(%rcx), %rax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(next_pair3):
|
|
|
ce426f |
+ addq %rax, %r11
|
|
|
ce426f |
+ movq %rdi, %rax
|
|
|
ce426f |
+ subq %r9, %rax
|
|
|
ce426f |
+ cmpq %r11, %rax
|
|
|
ce426f |
+ jl L(switch_strstr)
|
|
|
ce426f |
+ leaq -1(%r8), %rax
|
|
|
ce426f |
+ andq %rax, %r8
|
|
|
ce426f |
+ jne L(next_pair_index3)
|
|
|
ce426f |
+ jmp L(loop)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(switch_strstr):
|
|
|
ce426f |
+ movq %rdi, %rdi
|
|
|
ce426f |
+ jmp __strstr_sse2
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(cross_page):
|
|
|
ce426f |
+
|
|
|
ce426f |
+ movq %rdi, %rax
|
|
|
ce426f |
+ pxor %xmm0, %xmm0
|
|
|
ce426f |
+ andq $-64, %rax
|
|
|
ce426f |
+ movdqa (%rax), %xmm3
|
|
|
ce426f |
+ movdqu -1(%rax), %xmm4
|
|
|
ce426f |
+ movdqa %xmm3, %xmm8
|
|
|
ce426f |
+ movdqa 16(%rax), %xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm0, %xmm8
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ movdqa %xmm5, %xmm7
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqu 15(%rax), %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm0, %xmm7
|
|
|
ce426f |
+ por %xmm3, %xmm8
|
|
|
ce426f |
+ movdqa %xmm5, %xmm3
|
|
|
ce426f |
+ movdqa 32(%rax), %xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ movdqa %xmm5, %xmm6
|
|
|
ce426f |
+ pmovmskb %xmm8, %ecx
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqu 31(%rax), %xmm4
|
|
|
ce426f |
+ por %xmm3, %xmm7
|
|
|
ce426f |
+ movdqa %xmm5, %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm0, %xmm6
|
|
|
ce426f |
+ movdqa 48(%rax), %xmm5
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm4
|
|
|
ce426f |
+ pmovmskb %xmm7, %r8d
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ pcmpeqb %xmm5, %xmm0
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ movdqu 47(%rax), %xmm4
|
|
|
ce426f |
+ por %xmm3, %xmm6
|
|
|
ce426f |
+ movdqa %xmm5, %xmm3
|
|
|
ce426f |
+ salq $16, %r8
|
|
|
ce426f |
+ pcmpeqb %xmm1, %xmm4
|
|
|
ce426f |
+ pcmpeqb %xmm2, %xmm3
|
|
|
ce426f |
+ pmovmskb %xmm6, %r10d
|
|
|
ce426f |
+ pminub %xmm4, %xmm3
|
|
|
ce426f |
+ por %xmm3, %xmm0
|
|
|
ce426f |
+ salq $32, %r10
|
|
|
ce426f |
+ orq %r10, %r8
|
|
|
ce426f |
+ orq %rcx, %r8
|
|
|
ce426f |
+ movl %edi, %ecx
|
|
|
ce426f |
+ pmovmskb %xmm0, %edx
|
|
|
ce426f |
+ subl %eax, %ecx
|
|
|
ce426f |
+ salq $48, %rdx
|
|
|
ce426f |
+ orq %rdx, %r8
|
|
|
ce426f |
+ shrq %cl, %r8
|
|
|
ce426f |
+ je L(loop_header)
|
|
|
ce426f |
+L(next_pair_index4):
|
|
|
ce426f |
+ bsfq %r8, %rax
|
|
|
ce426f |
+ addq %rdi, %rax
|
|
|
ce426f |
+ cmpb $0, (%rax)
|
|
|
ce426f |
+ je L(zero)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ cmpq %rax,%rdi
|
|
|
ce426f |
+ je L(next_pair4)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ movzbl 2(%rsi), %edx
|
|
|
ce426f |
+ testb %dl, %dl
|
|
|
ce426f |
+ je L(found3)
|
|
|
ce426f |
+ cmpb 1(%rax), %dl
|
|
|
ce426f |
+ jne L(next_pair4)
|
|
|
ce426f |
+ xorl %edx, %edx
|
|
|
ce426f |
+ jmp L(pair_loop_start4)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(pair_loop4):
|
|
|
ce426f |
+ addq $1, %rdx
|
|
|
ce426f |
+ cmpb 1(%rax,%rdx), %cl
|
|
|
ce426f |
+ jne L(next_pair4)
|
|
|
ce426f |
+L(pair_loop_start4):
|
|
|
ce426f |
+ movzbl 3(%rsi,%rdx), %ecx
|
|
|
ce426f |
+ testb %cl, %cl
|
|
|
ce426f |
+ jne L(pair_loop4)
|
|
|
ce426f |
+L(found3):
|
|
|
ce426f |
+ subq $1, %rax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(next_pair4):
|
|
|
ce426f |
+ leaq -1(%r8), %rax
|
|
|
ce426f |
+ andq %rax, %r8
|
|
|
ce426f |
+ jne L(next_pair_index4)
|
|
|
ce426f |
+ jmp L(loop_header)
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(found):
|
|
|
ce426f |
+ rep
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .p2align 4
|
|
|
ce426f |
+L(zero):
|
|
|
ce426f |
+ xorl %eax, %eax
|
|
|
ce426f |
+ ret
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+END(__strstr_sse2_unaligned)
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/i386/i686/multiarch/strstr-c.c 2012-12-24 20:02:13.000000000 -0700
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/i386/i686/multiarch/strstr-c.c 2015-04-20 09:04:11.876569371 -0600
|
|
|
ce426f |
@@ -1,8 +1,6 @@
|
|
|
ce426f |
/* Multiple versions of strstr
|
|
|
ce426f |
All versions must be listed in ifunc-impl-list.c. */
|
|
|
ce426f |
|
|
|
ce426f |
-#include "init-arch.h"
|
|
|
ce426f |
-
|
|
|
ce426f |
#define STRSTR __strstr_ia32
|
|
|
ce426f |
#if defined SHARED && defined DO_VERSIONING && !defined NO_HIDDEN
|
|
|
ce426f |
#undef libc_hidden_builtin_def
|
|
|
ce426f |
@@ -17,13 +15,17 @@
|
|
|
ce426f |
|
|
|
ce426f |
#include "string/strstr.c"
|
|
|
ce426f |
|
|
|
ce426f |
+#include "init-arch.h"
|
|
|
ce426f |
+
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __strstr_sse42 attribute_hidden;
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __strstr_ia32 attribute_hidden;
|
|
|
ce426f |
|
|
|
ce426f |
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
|
|
|
ce426f |
ifunc symbol properly. */
|
|
|
ce426f |
extern __typeof (__redirect_strstr) __libc_strstr;
|
|
|
ce426f |
-libc_ifunc (__libc_strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32)
|
|
|
ce426f |
+libc_ifunc (__libc_strstr,
|
|
|
ce426f |
+ HAS_SSE4_2 && !use_unaligned_strstr () ?
|
|
|
ce426f |
+ __strstr_sse42 : __strstr_ia32)
|
|
|
ce426f |
|
|
|
ce426f |
#undef strstr
|
|
|
ce426f |
strong_alias (__libc_strstr, strstr)
|