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