diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2014-11-20 11:29:45 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2014-11-20 11:29:45 -0800 |
commit | 731885c1add5b5012654fe1a70572f033c8d21f8 (patch) | |
tree | f96c140d3301f41b2a3d236ca5fa057827927fdb /ld | |
parent | Add ifunc-main IFUNC tests (diff) | |
download | binutils-gdb-731885c1add5b5012654fe1a70572f033c8d21f8.tar.gz binutils-gdb-731885c1add5b5012654fe1a70572f033c8d21f8.tar.bz2 binutils-gdb-731885c1add5b5012654fe1a70572f033c8d21f8.zip |
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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-ifunc/ifunc-main.c | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 555d6bf6741..63f145eafdc 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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. * ld-ifunc/ifunc-lib.c: New file. * ld-ifunc/ifunc-main.c: Likewise. diff --git a/ld/testsuite/ld-ifunc/ifunc-main.c b/ld/testsuite/ld-ifunc/ifunc-main.c index a320cfbddaa..61e9934ae5d 100644 --- a/ld/testsuite/ld-ifunc/ifunc-main.c +++ b/ld/testsuite/ld-ifunc/ifunc-main.c @@ -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) |