glibc/sysdeps/generic/ifunc-sel.h
Nick Alcock de6591238b Do not stack-protect ifunc resolvers [BZ #7065]
When dynamically linking, ifunc resolvers are called before TLS is
initialized, so they cannot be safely stack-protected.

We avoid disabling stack-protection on large numbers of files by
using __attribute__ ((__optimize__ ("-fno-stack-protector")))
to turn it off just for the resolvers themselves.  (We provide
the attribute even when statically linking, because we will later
use it elsewhere too.)
2016-12-26 10:08:41 +01:00

29 lines
430 B
C

/* Used by the elf ifunc tests. */
#ifndef ELF_IFUNC_SEL_H
#define ELF_IFUNC_SEL_H 1
extern int global;
static inline void *
inhibit_stack_protector
ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void))
{
switch (global)
{
case 1:
return f1;
case -1:
return f2;
default:
return f3;
}
}
static inline void *
inhibit_stack_protector
ifunc_one (int (*f1) (void))
{
return f1;
}
#endif