mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-18 14:53:32 +08:00
Always load function pointer into a stack variable
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.
This commit is contained in:
parent
5f7cbeec7d
commit
731885c1ad
@ -1,3 +1,8 @@
|
||||
2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ld-ifunc/ifunc-main.c (get_bar): New function.
|
||||
(main): Use it.
|
||||
|
||||
2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ld-ifunc/ifunc.exp: Run ifunc-main.
|
||||
|
@ -3,12 +3,21 @@
|
||||
extern int foo(void);
|
||||
extern int bar(void);
|
||||
|
||||
int (*foo_ptr)(void) = foo;
|
||||
typedef int (*func_p) (void);
|
||||
|
||||
func_p foo_ptr = foo;
|
||||
|
||||
func_p
|
||||
__attribute__((noinline))
|
||||
get_bar (void)
|
||||
{
|
||||
return bar;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int (*bar_ptr)(void) = bar;
|
||||
func_p bar_ptr = get_bar ();
|
||||
if (bar_ptr != bar)
|
||||
__builtin_abort ();
|
||||
if (bar_ptr() != -1)
|
||||
|
Loading…
Reference in New Issue
Block a user