about summary refs log tree commit diff
path: root/sysdeps/x86
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/x86')
-rw-r--r--sysdeps/x86/Makefile9
-rw-r--r--sysdeps/x86/tst-ifunc-cpu1-main.c10
-rw-r--r--sysdeps/x86/tst-ifunc-cpu1-mod.c24
3 files changed, 43 insertions, 0 deletions
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 3e87a77069..79a44061e9 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -6,4 +6,13 @@ tests: $(objpfx)tst-xmmymm.out
 $(objpfx)tst-xmmymm.out: ../sysdeps/x86/tst-xmmymm.sh $(objpfx)ld.so
 	@echo "Checking ld.so for SSE register use.  This will take a few seconds..."
 	$(SHELL) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@
+
+ifeq (yesyes,$(build-shared)$(multi-arch))
+tests += tst-ifunc-cpu1-main
+modules-names += tst-ifunc-cpu1-mod
+
+tst-ifunc-cpu1-mod.so-no-z-defs = yes
+
+$(objpfx)tst-ifunc-cpu1-main: $(objpfx)tst-ifunc-cpu1-mod.so
+endif
 endif
diff --git a/sysdeps/x86/tst-ifunc-cpu1-main.c b/sysdeps/x86/tst-ifunc-cpu1-main.c
new file mode 100644
index 0000000000..37c16e2e1e
--- /dev/null
+++ b/sysdeps/x86/tst-ifunc-cpu1-main.c
@@ -0,0 +1,10 @@
+/* Test function pointer to local STT_GNU_IFUNC function.  */
+
+extern void (*foo_ptr) (void);
+
+int
+main (void)
+{
+  foo_ptr ();
+  return 0;
+}
diff --git a/sysdeps/x86/tst-ifunc-cpu1-mod.c b/sysdeps/x86/tst-ifunc-cpu1-mod.c
new file mode 100644
index 0000000000..08ff30f41e
--- /dev/null
+++ b/sysdeps/x86/tst-ifunc-cpu1-mod.c
@@ -0,0 +1,24 @@
+#include <init-arch.h>
+
+static void
+one (void)
+{
+}
+
+static void
+two (void)
+{
+}
+
+void * foo_ifunc (void) __asm__ ("foo") attribute_hidden;
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+  const struct cpu_features * cpu = __get_cpu_features ();
+  return cpu->max_cpuid > 1 ? two : one;
+}
+
+extern void foo (void) attribute_hidden;
+void (*foo_ptr) (void) = foo;