This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- From: Zack Weinberg <zackw at panix dot com>
- To: libc-alpha at sourceware dot org
- Date: Sat, 8 Aug 2015 21:14:40 -0400
- Subject: [PATCH] Remove unnecessary IFUNC dispatch for __memset_chk.
- Authentication-results: sourceware.org; auth=none
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
__memset_chk does a bounds check (which the C compiler will optimize
just fine) and then calls memset. That call will itself go through
IFUNC dispatch, so there is no need to have extra goo for __memset_chk.
I tripped over this because, for patches still in development, I
needed to add a libc_hidden_def for __memset_chk. I don't see any
reason not to put this in now, though.
zw
* sysdeps/i386/i586/memset_chk.S: Delete.
* sysdeps/i386/i686/memset_chk.S: Delete.
* sysdeps/i386/i686/multiarch/memset_chk.S: Delete.
* sysdeps/x86_64/memset_chk.S: Delete.
* sysdeps/x86_64/multiarch/memset_chk.S: Delete.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c
* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Remove entry for __memset_chk.
- ---
sysdeps/i386/i586/memset_chk.S | 1 -
sysdeps/i386/i686/memset_chk.S | 34 ---------
sysdeps/i386/i686/multiarch/ifunc-impl-list.c | 9 ---
sysdeps/i386/i686/multiarch/memset_chk.S | 106 --------------------------
sysdeps/x86_64/memset_chk.S | 33 --------
sysdeps/x86_64/multiarch/ifunc-impl-list.c | 6 --
sysdeps/x86_64/multiarch/memset_chk.S | 44 -----------
7 files changed, 233 deletions(-)
delete mode 100644 sysdeps/i386/i586/memset_chk.S
delete mode 100644 sysdeps/i386/i686/memset_chk.S
delete mode 100644 sysdeps/i386/i686/multiarch/memset_chk.S
delete mode 100644 sysdeps/x86_64/memset_chk.S
delete mode 100644 sysdeps/x86_64/multiarch/memset_chk.S
diff --git a/sysdeps/i386/i586/memset_chk.S b/sysdeps/i386/i586/memset_chk.S
deleted file mode 100644
index 09f9d42..0000000
- --- a/sysdeps/i386/i586/memset_chk.S
+++ /dev/null
@@ -1 +0,0 @@
- -#include <sysdeps/i386/i686/memset_chk.S>
diff --git a/sysdeps/i386/i686/memset_chk.S b/sysdeps/i386/i686/memset_chk.S
deleted file mode 100644
index da982fd..0000000
- --- a/sysdeps/i386/i686/memset_chk.S
+++ /dev/null
@@ -1,34 +0,0 @@
- -/* Checking memset for i686.
- - Copyright (C) 2004-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 <sysdep.h>
- -#include "asm-syntax.h"
- -
- -#ifndef SHARED
- - /* For libc.so this is defined in memset.S.
- - For libc.a, this is a separate source to avoid
- - memset bringing in __chk_fail and all routines
- - it calls. */
- - .text
- -ENTRY (__memset_chk)
- - movl 12(%esp), %eax
- - cmpl %eax, 16(%esp)
- - jb __chk_fail
- - jmp memset
- -END (__memset_chk)
- -#endif
diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
index 92366a7..7a734ab 100644
- --- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
+++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c
@@ -93,15 +93,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
IFUNC_IMPL_ADD (array, i, memrchr, HAS_SSE2, __memrchr_sse2)
IFUNC_IMPL_ADD (array, i, memrchr, 1, __memrchr_ia32))
- - /* Support sysdeps/i386/i686/multiarch/memset_chk.S. */
- - IFUNC_IMPL (i, name, __memset_chk,
- - IFUNC_IMPL_ADD (array, i, __memset_chk, HAS_SSE2,
- - __memset_chk_sse2_rep)
- - IFUNC_IMPL_ADD (array, i, __memset_chk, HAS_SSE2,
- - __memset_chk_sse2)
- - IFUNC_IMPL_ADD (array, i, __memset_chk, 1,
- - __memset_chk_ia32))
- -
/* Support sysdeps/i386/i686/multiarch/memset.S. */
IFUNC_IMPL (i, name, memset,
IFUNC_IMPL_ADD (array, i, memset, HAS_SSE2,
diff --git a/sysdeps/i386/i686/multiarch/memset_chk.S b/sysdeps/i386/i686/multiarch/memset_chk.S
deleted file mode 100644
index a770c0d..0000000
- --- a/sysdeps/i386/i686/multiarch/memset_chk.S
+++ /dev/null
@@ -1,106 +0,0 @@
- -/* Multiple versions of __memset_chk
- - 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 lib. */
- -#if IS_IN (libc)
- -# ifdef SHARED
- - .text
- -ENTRY(__memset_chk)
- - .type __memset_chk, @gnu_indirect_function
- - pushl %ebx
- - cfi_adjust_cfa_offset (4)
- - cfi_rel_offset (ebx, 0)
- - LOAD_PIC_REG(bx)
- - cmpl $0, KIND_OFFSET+__cpu_features@GOTOFF(%ebx)
- - jne 1f
- - call __init_cpu_features
- -1: leal __memset_chk_ia32@GOTOFF(%ebx), %eax
- - testl $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features@GOTOFF(%ebx)
- - jz 2f
- - leal __memset_chk_sse2@GOTOFF(%ebx), %eax
- - testl $bit_Fast_Rep_String, FEATURE_OFFSET+index_Fast_Rep_String+__cpu_features@GOTOFF(%ebx)
- - jz 2f
- - leal __memset_chk_sse2_rep@GOTOFF(%ebx), %eax
- -2: popl %ebx
- - cfi_adjust_cfa_offset (-4)
- - cfi_restore (ebx)
- - ret
- -END(__memset_chk)
- -
- -strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
- - .section .gnu.warning.__memset_zero_constant_len_parameter
- - .string "memset used with constant zero length parameter; this could be due to transposed parameters"
- -# else
- - .text
- -ENTRY(__memset_chk)
- - .type __memset_chk, @gnu_indirect_function
- - cmpl $0, KIND_OFFSET+__cpu_features
- - jne 1f
- - call __init_cpu_features
- -1: leal __memset_chk_ia32, %eax
- - testl $bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features
- - jz 2f
- - leal __memset_chk_sse2, %eax
- - testl $bit_Fast_Rep_String, FEATURE_OFFSET+index_Fast_Rep_String+__cpu_features
- - jz 2f
- - leal __memset_chk_sse2_rep, %eax
- -2: ret
- -END(__memset_chk)
- -
- - .type __memset_chk_sse2, @function
- - .p2align 4;
- -__memset_chk_sse2:
- - cfi_startproc
- - CALL_MCOUNT
- - movl 12(%esp), %eax
- - cmpl %eax, 16(%esp)
- - jb __chk_fail
- - jmp __memset_sse2
- - cfi_endproc
- - .size __memset_chk_sse2, .-__memset_chk_sse2
- -
- - .type __memset_chk_sse2_rep, @function
- - .p2align 4;
- -__memset_chk_sse2_rep:
- - cfi_startproc
- - CALL_MCOUNT
- - movl 12(%esp), %eax
- - cmpl %eax, 16(%esp)
- - jb __chk_fail
- - jmp __memset_sse2_rep
- - cfi_endproc
- - .size __memset_chk_sse2_rep, .-__memset_chk_sse2_rep
- -
- - .type __memset_chk_ia32, @function
- - .p2align 4;
- -__memset_chk_ia32:
- - cfi_startproc
- - CALL_MCOUNT
- - movl 12(%esp), %eax
- - cmpl %eax, 16(%esp)
- - jb __chk_fail
- - jmp __memset_ia32
- - cfi_endproc
- - .size __memset_chk_ia32, .-__memset_chk_ia32
- -# endif
- -#endif
diff --git a/sysdeps/x86_64/memset_chk.S b/sysdeps/x86_64/memset_chk.S
deleted file mode 100644
index 7020426..0000000
- --- a/sysdeps/x86_64/memset_chk.S
+++ /dev/null
@@ -1,33 +0,0 @@
- -/* Checking memset for x86-64.
- - Copyright (C) 2004-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 <sysdep.h>
- -#include "asm-syntax.h"
- -
- -#ifndef SHARED
- - /* For libc.so this is defined in memset.S.
- - For libc.a, this is a separate source to avoid
- - memset bringing in __chk_fail and all routines
- - it calls. */
- - .text
- -ENTRY (__memset_chk)
- - cmpq %rdx, %rcx
- - jb __chk_fail
- - jmp memset
- -END (__memset_chk)
- -#endif
diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
index b64e4f1..4d54994 100644
- --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
@@ -66,12 +66,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_sse2))
#ifdef HAVE_AVX2_SUPPORT
- - /* Support sysdeps/x86_64/multiarch/memset_chk.S. */
- - IFUNC_IMPL (i, name, __memset_chk,
- - IFUNC_IMPL_ADD (array, i, __memset_chk, 1, __memset_chk_sse2)
- - IFUNC_IMPL_ADD (array, i, __memset_chk, HAS_AVX2,
- - __memset_chk_avx2))
- -
/* Support sysdeps/x86_64/multiarch/memset.S. */
IFUNC_IMPL (i, name, memset,
IFUNC_IMPL_ADD (array, i, memset, 1, __memset_sse2)
diff --git a/sysdeps/x86_64/multiarch/memset_chk.S b/sysdeps/x86_64/multiarch/memset_chk.S
deleted file mode 100644
index 64fed31..0000000
- --- a/sysdeps/x86_64/multiarch/memset_chk.S
+++ /dev/null
@@ -1,44 +0,0 @@
- -/* Multiple versions of memset_chk
- - All versions must be listed in ifunc-impl-list.c.
- - Copyright (C) 2014-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 <sysdep.h>
- -#include <init-arch.h>
- -
- -/* Define multiple versions only for the definition in lib. */
- -#if IS_IN (libc)
- -# if defined SHARED && defined HAVE_AVX2_SUPPORT
- -ENTRY(__memset_chk)
- - .type __memset_chk, @gnu_indirect_function
- - cmpl $0, __cpu_features+KIND_OFFSET(%rip)
- - jne 1f
- - call __init_cpu_features
- -1: leaq __memset_chk_sse2(%rip), %rax
- - testl $bit_AVX2_Usable, __cpu_features+FEATURE_OFFSET+index_AVX2_Usable(%rip)
- - jz 2f
- - leaq __memset_chk_avx2(%rip), %rax
- -2: ret
- -END(__memset_chk)
- -
- -strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
- - .section .gnu.warning.__memset_zero_constant_len_parameter
- - .string "memset used with constant zero length parameter; this could be due to transposed parameters"
- -# else
- -# include "../memset_chk.S"
- -# endif
- -#endif
- --
2.5.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJVxq3CAAoJEJH8wytnaapkW0QP/3ylyNeTxuT48u3DSM+BG85R
/7nY4/0Ofw9EWJrhVwOEJI0bDkoTKj5FEdsSLGnMqS/Shzuu2OEez/JUKgwdNR4u
r+Fz3PCLwwtdpJviOFbrcWbAa/mdvjWEMMwVwKNtHqKc16kpSnGZ19wuBlZcX+dO
imRJjgW3JEy0u2DSxR73X16JP6masV7w/XVhk8myyDGIESCMMyq3l4rg0EgRtuK9
9EBsjpnZeTZFu13RHDoDTVgHw323/1Sb2nJetJU5y2FBbKE2S4mCKuc0UGJacNpr
vT8kOvh6uJ6AfQ0eUy3lV6WUtGzt4Mk3LKAKWROE1dVinQqd3l4g+UWejZG8Sfp3
aZgj2MMn2ZtReAu20eyo0xJNqdRo1eQw1w8M9PhLipjU6Ru0VO7s4JketA2SsGGd
aeUFI0s98wZAXEzjWNslDzLEltAmo5wUGxxUruxtAezavmu6k/m+y5mpwKEy4x5x
Yc8bUhACiYbTQMlGOoO0zQ4FGqgyr++u9ObAo5vsfF/1ScQpP7ckolqAPFuXRyn6
0JfmFzra7qS1+IfOOcV+AomReY/+wnyZvtbmODmHJ9HKytZgSLLvJRnQwO4zaxKT
BP+7sSundhrzaf8PYzbIUXdzc9iiOXNz2Zhn9FUGbBcigf987BF8Rjs0+W+up7gh
eXGbAHgUXibpn5i3qCLC
=tp8P
-----END PGP SIGNATURE-----