]> git.ipfire.org Git - thirdparty/glibc.git/commit
x86: Use __always_inline on ifunc auxiliary functions
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 4 Aug 2022 12:41:29 +0000 (09:41 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 9 Apr 2025 11:45:23 +0000 (08:45 -0300)
commit005c020d98b91c75ffcc43339ed2f438b104d372
tree76e31b251b4a6d1f0dbc56d6609511d4e756f5ae
parent9b474dfc60b156a5ba2f6bfe024418a06e5132cc
x86: Use __always_inline on ifunc auxiliary functions

clang does correctly propagate the no_stack_protector attribute for
inline function used in ifunc selectors.  For instance, the exp function
is expanded as:

  static inline void *
  ieee754_exp_ifunc_selector (void)
  {
    [...]
  }

  extern __typeof (__redirect_ieee754_exp) __ieee754_exp
    __attribute__ ((ifunc ("__ieee754_exp" "_ifunc")));

  static __attribute__((no_stack_protector)) __typeof (__redirect_ieee754_exp) *i
  __ieee754_exp_ifunc (void)
  {
    __typeof (__redirect_ieee754_exp) *res = ieee754_exp_ifunc_selector ();
    return res;
  };

The ifunc selection ended being compiled with -fstack-protector, and
with debug function set to the ifunc selector
(ieee754_exp_ifunc_selector) auxiliary function instead of the
selector itself.

The ifunc selector are called early, before TCB is setup, which
causes SIGSEGV for statically linked binaries.

To fix it use __always_inline instead of inline.  It should not change
code generation on gcc and it fixes the code generation issue on
clang.  It also fixes function debug information.
21 files changed:
sysdeps/x86_64/fpu/multiarch/ifunc-avx-fma4.h
sysdeps/x86_64/fpu/multiarch/ifunc-fma.h
sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h
sysdeps/x86_64/multiarch/ifunc-avx2.h
sysdeps/x86_64/multiarch/ifunc-evex.h
sysdeps/x86_64/multiarch/ifunc-memcmp.h
sysdeps/x86_64/multiarch/ifunc-memmove.h
sysdeps/x86_64/multiarch/ifunc-memset.h
sysdeps/x86_64/multiarch/ifunc-sse4_2.h
sysdeps/x86_64/multiarch/ifunc-strcasecmp.h
sysdeps/x86_64/multiarch/ifunc-strcpy.h
sysdeps/x86_64/multiarch/ifunc-strncpy.h
sysdeps/x86_64/multiarch/ifunc-wcs.h
sysdeps/x86_64/multiarch/ifunc-wcslen.h
sysdeps/x86_64/multiarch/ifunc-wmemset.h
sysdeps/x86_64/multiarch/strchr.c
sysdeps/x86_64/multiarch/strcmp.c
sysdeps/x86_64/multiarch/strncmp.c
sysdeps/x86_64/multiarch/strstr.c
sysdeps/x86_64/multiarch/wcscpy.c