aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-ifunc
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-11-20 10:48:47 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-11-20 10:49:46 -0800
commit5f7cbeec7d698c4881ffbb55d9c3288536098d32 (patch)
treebc0ef358c0db4acfcf1d347b05514b4310edec9b /ld/testsuite/ld-ifunc
parent7e7cbeb3a21dd677d35321c5eafae75e3dc0dc1a (diff)
downloadgdb-5f7cbeec7d698c4881ffbb55d9c3288536098d32.zip
gdb-5f7cbeec7d698c4881ffbb55d9c3288536098d32.tar.gz
gdb-5f7cbeec7d698c4881ffbb55d9c3288536098d32.tar.bz2
Add ifunc-main IFUNC tests
* 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.
Diffstat (limited to 'ld/testsuite/ld-ifunc')
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-lib.c29
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-main.c29
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-main.out1
-rw-r--r--ld/testsuite/ld-ifunc/ifunc.exp28
4 files changed, 87 insertions, 0 deletions
diff --git a/ld/testsuite/ld-ifunc/ifunc-lib.c b/ld/testsuite/ld-ifunc/ifunc-lib.c
new file mode 100644
index 0000000..13ca250
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-lib.c
@@ -0,0 +1,29 @@
+static int
+one (void)
+{
+ return 1;
+}
+
+static int
+minus_one (void)
+{
+ return -1;
+}
+
+void * foo_ifunc (void) __asm__ ("foo");
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+ return one;
+}
+
+void * bar_ifunc (void) __asm__ ("bar");
+__asm__(".type bar, %gnu_indirect_function");
+
+void *
+bar_ifunc (void)
+{
+ return minus_one;
+}
diff --git a/ld/testsuite/ld-ifunc/ifunc-main.c b/ld/testsuite/ld-ifunc/ifunc-main.c
new file mode 100644
index 0000000..a320cfb
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+extern int foo(void);
+extern int bar(void);
+
+int (*foo_ptr)(void) = foo;
+
+int
+main (void)
+{
+ int (*bar_ptr)(void) = 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;
+}
diff --git a/ld/testsuite/ld-ifunc/ifunc-main.out b/ld/testsuite/ld-ifunc/ifunc-main.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-main.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index d2382f8..03789a9 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -418,6 +418,17 @@ if { ![check_ifunc_available] } {
return
}
+run_cc_link_tests [list \
+ [list \
+ "Build ifunc-lib.so" \
+ "-shared" \
+ "-fPIC" \
+ { ifunc-lib.c } \
+ {} \
+ "libifunc-lib.so" \
+ ] \
+]
+
run_ld_link_exec_tests [] [list \
[list \
"Run pr16467" \
@@ -428,4 +439,21 @@ run_ld_link_exec_tests [] [list \
"pr16467.out" \
"" \
] \
+ [list \
+ "Run ifunc-main" \
+ "tmpdir/libifunc-lib.so" \
+ "" \
+ { ifunc-main.c } \
+ "ifunc-main" \
+ "ifunc-main.out" \
+ ] \
+ [list \
+ "Run ifunc-main with -fpic" \
+ "tmpdir/libifunc-lib.so" \
+ "" \
+ { ifunc-main.c } \
+ "ifunc-main" \
+ "ifunc-main.out" \
+ "-fpic" \
+ ] \
]