summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-04-26 13:01:27 +0100
committerPedro Alves <palves@redhat.com>2018-04-26 13:11:09 +0100
commitc7075ad5030c4c2e79a04f3517689b751ff41860 (patch)
tree56c9f7a828468310dc0ce42319f220f4cb938bf5 /gdb/testsuite/gdb.base/gnu-ifunc-lib.c
parentbfa5bd2ab31a8abb23cb442d51fe6c3836028880 (diff)
downloadbinutils-gdb-c7075ad5030c4c2e79a04f3517689b751ff41860.tar.gz
Extend GNU ifunc testcases
This patch extends/rewrites the gdb.base/gnu-ifunc.exp testcase to cover the many different fixes in earlier patches. (This was actually what encovered most of the problems.) The current testcase uses an ifunc symbol with the same name as the ifunc resolver symbol and makes sure to compile the ifunc resolver without debug info. That does not model how ifuncs are implemented in gcc/ifunc nowadays. Instead, what we have is that the glibc ifunc resolvers nowadays are written in C and end up with debug info. Also, in some cases the ifunc target is written in assembly, but in other cases it's written in C. In the case of target function written in C, if the target function has debug info, when we set a break on the ifunc, we want to set it past the prologue of the target function. Currently GDB gets that wrong. To make sure we cover all the different scenarios, the testcase is tweaked to cover all the different combinations of - An ifunc resolver with the same name as the user-visible symbol vs an ifunc resolver with a different name as the user-visible symbol. - ifunc resolver compiled with and without debug info. - ifunc target function compiled with and without debug info. The testcase currently sets breakpoints on ifuncs, calls ifunc functions, steps into ifunc functions, etc. After this series, this all works and the testcase passes cleanly. While working on this, I noticed that "b gnu_ifunc" before and after the inferior resolved the ifunc would end up with a breakpoint with different locations. That's now covered by new tests inside the new "set-break" procedure. It also tests other things like making sure we can't call an ifunc without a return-type case if we don't know the type of the target. And making sure that we pass enough arguments when we do know the type. gdb/testsuite/ChangeLog: 2018-04-26 Pedro Alves <palves@redhat.com> * gdb.base/gnu-ifunc-final.c: New file. * gdb.base/gnu-ifunc.c (final): Delete, moved to gnu-ifunc-final.c. * gdb.base/gnu-ifunc.exp (executable): Delete. (staticexecutable): Adjust. (lib_opts, exec_opts): Delete. (make_binsuffix, build, set-break): New procedures. (misc_tests): New, with tests factored out from the top level. (top level): Test different combinations of ifunc resolver name, resolver with and with debug info, and ifunc target with and without debug info. Wrap static tests with with_target_prefix.
Diffstat (limited to 'gdb/testsuite/gdb.base/gnu-ifunc-lib.c')
-rw-r--r--gdb/testsuite/gdb.base/gnu-ifunc-lib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
index b9d446c92fa..7aac81faec6 100644
--- a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
+++ b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
@@ -22,10 +22,14 @@ extern int final (int arg);
typedef int (*final_t) (int arg);
+#ifndef IFUNC_RESOLVER_ATTR
asm (".type gnu_ifunc, %gnu_indirect_function");
-
final_t
gnu_ifunc (unsigned long hwcap)
+#else
+final_t
+gnu_ifunc_resolver (unsigned long hwcap)
+#endif
{
resolver_hwcap = hwcap;
if (! gnu_ifunc_initialized)
@@ -33,3 +37,9 @@ gnu_ifunc (unsigned long hwcap)
else
return final;
}
+
+#ifdef IFUNC_RESOLVER_ATTR
+extern int gnu_ifunc (int arg);
+
+__typeof (gnu_ifunc) gnu_ifunc __attribute__ ((ifunc ("gnu_ifunc_resolver")));
+#endif