1/* Multiple versions of __memmove_chk
2 All versions must be listed in ifunc-impl-list.c.
3 Copyright (C) 2016 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <sysdep.h>
21#include <init-arch.h>
22
23/* Define multiple versions only for the definition in lib and for
24 DSO. There are no multiarch memmove functions for static binaries.
25 */
26#if IS_IN (libc)
27# ifdef SHARED
28 .text
29ENTRY(__memmove_chk)
30 .type __memmove_chk, @gnu_indirect_function
31 LOAD_RTLD_GLOBAL_RO_RDX
32 HAS_ARCH_FEATURE (Prefer_No_AVX512)
33 jnz 1f
34 HAS_ARCH_FEATURE (AVX512F_Usable)
35 jz 1f
36 lea __memmove_chk_avx512_no_vzeroupper(%rip), %RAX_LP
37 HAS_ARCH_FEATURE (Prefer_No_VZEROUPPER)
38 jnz 2f
39 lea __memmove_chk_avx512_unaligned_erms(%rip), %RAX_LP
40 HAS_CPU_FEATURE (ERMS)
41 jnz 2f
42 lea __memmove_chk_avx512_unaligned(%rip), %RAX_LP
43 ret
441: lea __memmove_chk_avx_unaligned(%rip), %RAX_LP
45 HAS_ARCH_FEATURE (AVX_Fast_Unaligned_Load)
46 jz L(Fast_Unaligned_Load)
47 HAS_CPU_FEATURE (ERMS)
48 jz 2f
49 lea __memmove_chk_avx_unaligned_erms(%rip), %RAX_LP
50 ret
51L(Fast_Unaligned_Load):
52 lea __memmove_chk_sse2_unaligned(%rip), %RAX_LP
53 HAS_ARCH_FEATURE (Fast_Unaligned_Copy)
54 jz L(SSSE3)
55 HAS_CPU_FEATURE (ERMS)
56 jz 2f
57 lea __memmove_chk_sse2_unaligned_erms(%rip), %RAX_LP
58 ret
59L(SSSE3):
60 HAS_CPU_FEATURE (SSSE3)
61 jz 2f
62 lea __memmove_chk_ssse3_back(%rip), %RAX_LP
63 HAS_ARCH_FEATURE (Fast_Copy_Backward)
64 jnz 2f
65 lea __memmove_chk_ssse3(%rip), %RAX_LP
662: ret
67END(__memmove_chk)
68# else
69# include "../memmove_chk.S"
70# endif
71#endif
72