2
0
mirror of git://sourceware.org/git/glibc.git synced 2025-04-24 14:41:06 +08:00
glibc/elf/ifuncmain5.c
Florian Weimer 6c9e370891 elf: Disable some subtests of ifuncmain1, ifuncmain5 for !PIE
(cherry picked from commit 9cc9d61ee12f2f8620d8e0ea3c42af02bf07fe1e)
2024-05-02 23:18:23 +02:00

48 lines
765 B
C

/* Test STT_GNU_IFUNC symbols with dynamic function pointer only. */
#include <stdlib.h>
extern int foo (void);
extern int foo_protected (void);
typedef int (*foo_p) (void);
foo_p
__attribute__ ((noinline))
get_foo (void)
{
return foo;
}
/* Address-significant access to protected symbols is not supported in
position-dependent mode on several architectures because GCC
generates relocations that assume that the address is local to the
main program. */
#ifdef __PIE__
foo_p
__attribute__ ((noinline))
get_foo_protected (void)
{
return foo_protected;
}
#endif
int
main (void)
{
foo_p p;
p = get_foo ();
if ((*p) () != -1)
abort ();
#ifdef __PIE__
p = get_foo_protected ();
if ((*p) () != 0)
abort ();
#endif
return 0;
}