This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/8] Use gcc attribute ifunc in libc_ifunc macro instead of inline assembly due to false debuginfo.



On 06/23/2016 06:55 AM, Stefan Liebler wrote:
> diff --git a/include/libc-symbols.h b/include/libc-symbols.h
> index 4548e09..a77308a 100644
> --- a/include/libc-symbols.h
> +++ b/include/libc-symbols.h
> @@ -714,26 +714,21 @@ for linking")
>  #endif
> 
>  /* Marker used for indirection function symbols.  */
> -#define libc_ifunc(name, expr)						\
> -  extern void *name##_ifunc (void) __asm__ (#name);			\
> -  void *name##_ifunc (void)						\
> +#define __ifunc(name, expr, arg, init)					\
> +  extern __typeof (name) name __attribute__ ((ifunc(#name "_ifunc")));	\
> +  static void *name##_ifunc (arg)					\
>    {									\
> -    INIT_ARCH ();							\
> +    init ();								\
>      __typeof (name) *res = expr;					\
>      return res;								\
> -  }									\
> -  __asm__ (".type " #name ", %gnu_indirect_function");
> +  }
> +
> +#define libc_ifunc(name, expr) __ifunc (name, expr, void, INIT_ARCH)
> 
>  /* The body of the function is supposed to use __get_cpu_features
>     which will, if necessary, initialize the data first.  */
> -#define libm_ifunc(name, expr)						\
> -  extern void *name##_ifunc (void) __asm__ (#name);			\
> -  void *name##_ifunc (void)						\
> -  {									\
> -    __typeof (name) *res = expr;					\
> -    return res;								\
> -  }									\
> -  __asm__ (".type " #name ", %gnu_indirect_function");
> +#define libm_ifunc_init()
> +#define libm_ifunc(name, expr) __ifunc (name, expr, void, libm_ifunc_init)
> 
>  #ifdef HAVE_ASM_SET_DIRECTIVE
>  # define libc_ifunc_hidden_def1(local, name)				\

I'm suspecting this attribute is not always enabled on all toolchains.

Testing this out with the system toolchain on a ppc64le P8 Ubuntu 14.04 system,
I was greeted with:

../sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c:35:13: error: ifunc is not supported in this configuration

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) 


What is the preferred method for exposing ifunc'ed API?  I see both
strong and weak aliases used in ppc multiarch code.  GCC claims only
strong are supported, but both macros are used throughout ppc
multiarch and seem to work.

Likewise, many of the changes add an extra declaration for the 
ifunc'ed symbol.  Isn't this now handled by the __ifunc() macro?
Can these redundant declarations be removed?

Simiarly, are all the macro redirections necessary? The redirects
in s_finitef.c for double and long double seem unnecessary, and
removing all them worked as expected.

Maybe another macro like libc_ifunc_public would be useful to
properly declare, and alias an indirect function?  That would
simplify much ppc code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]