mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
731885c1ad
This patch makes sure that compiler won't optimize out loading function into a stack variable. * ld-ifunc/ifunc-main.c (get_bar): New function. (main): Use it.
39 lines
541 B
C
39 lines
541 B
C
#include <stdio.h>
|
|
|
|
extern int foo(void);
|
|
extern int bar(void);
|
|
|
|
typedef int (*func_p) (void);
|
|
|
|
func_p foo_ptr = foo;
|
|
|
|
func_p
|
|
__attribute__((noinline))
|
|
get_bar (void)
|
|
{
|
|
return bar;
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
func_p bar_ptr = get_bar ();
|
|
if (bar_ptr != bar)
|
|
__builtin_abort ();
|
|
if (bar_ptr() != -1)
|
|
__builtin_abort ();
|
|
if (bar() != -1)
|
|
__builtin_abort ();
|
|
|
|
if (foo_ptr != foo)
|
|
__builtin_abort ();
|
|
if (foo_ptr() != 1)
|
|
__builtin_abort ();
|
|
if (foo() != 1)
|
|
__builtin_abort ();
|
|
|
|
printf ("OK\n");
|
|
|
|
return 0;
|
|
}
|