This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Add ifunc-main IFUNC tests
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 20 Nov 2014 11:33:25 -0800
- Subject: Re: PATCH: Add ifunc-main IFUNC tests
- Authentication-results: sourceware.org; auth=none
- References: <20141120185031 dot GA18581 at intel dot com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Thu, Nov 20, 2014 at 10:50:31AM -0800, H.J. Lu wrote:
> Hi,
>
> I checked in this patch to add ifunc-main IFUNC tests.
>
> H.J.
> ---
> diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
> index f8478bd..555d6bf 100644
> --- a/ld/testsuite/ChangeLog
> +++ b/ld/testsuite/ChangeLog
> @@ -1,5 +1,12 @@
> 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.
> + * ld-ifunc/ifunc-main.out: Likewise.
> +
> +2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
> +
> * lib/ld-lib.exp (check_ifunc_available): New.
> * ld-ifunc/ifunc.exp: Run IFUNC run-time tests only if IFUNC
I checked in this patch to make sure that compiler won't optimize out
loading function into a local variable.
H.J.
--
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 555d6bf..63f145e 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 a320cfb..61e9934 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)