arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1150282.patch

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