socsvn commit: r269044 - in soc2014/op/tests/ifunc-vs-kpatch: . clang gcc src
op at FreeBSD.org
op at FreeBSD.org
Wed Jun 4 09:45:56 UTC 2014
Author: op
Date: Wed Jun 4 09:45:52 2014
New Revision: 269044
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269044
Log:
added __attribute__((ifunc("foo))) tester
Signed-off-by: Oliver Pinter <oliver.pntr at gmail.com>
Added:
soc2014/op/tests/ifunc-vs-kpatch/
soc2014/op/tests/ifunc-vs-kpatch/Makefile
soc2014/op/tests/ifunc-vs-kpatch/clang/
soc2014/op/tests/ifunc-vs-kpatch/clang/Makefile
soc2014/op/tests/ifunc-vs-kpatch/clang/test-ifunc.c (contents, props changed)
soc2014/op/tests/ifunc-vs-kpatch/gcc/
soc2014/op/tests/ifunc-vs-kpatch/gcc/Makefile
soc2014/op/tests/ifunc-vs-kpatch/gcc/test-ifunc.c (contents, props changed)
soc2014/op/tests/ifunc-vs-kpatch/src/
soc2014/op/tests/ifunc-vs-kpatch/src/test-ifunc.c
Added: soc2014/op/tests/ifunc-vs-kpatch/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/Makefile Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1,3 @@
+SUBDIR= gcc clang
+
+.include <bsd.subdir.mk>
Added: soc2014/op/tests/ifunc-vs-kpatch/clang/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/clang/Makefile Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1,8 @@
+CC=clang
+
+PROG= test-ifunc
+
+NO_PIE=
+NO_MAN=
+
+.include <bsd.prog.mk>
Added: soc2014/op/tests/ifunc-vs-kpatch/clang/test-ifunc.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/clang/test-ifunc.c Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1 @@
+link ../src/test-ifunc.c
\ No newline at end of file
Added: soc2014/op/tests/ifunc-vs-kpatch/gcc/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/gcc/Makefile Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1,8 @@
+CC= gcc49
+
+PROG= test-ifunc
+
+NO_PIE=
+NO_MAN=
+
+.include <bsd.prog.mk>
Added: soc2014/op/tests/ifunc-vs-kpatch/gcc/test-ifunc.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/gcc/test-ifunc.c Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1 @@
+link ../src/test-ifunc.c
\ No newline at end of file
Added: soc2014/op/tests/ifunc-vs-kpatch/src/test-ifunc.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/src/test-ifunc.c Wed Jun 4 09:45:52 2014 (r269044)
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <sys/time.h>
+
+#define ROUNDS 10000000
+
+void *__a (void);
+void *__b (void);
+void *A (void) __attribute__ ((ifunc ("disp_a")));
+void B(void);
+void C(void);
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ struct timespec start;
+ struct timespec stop;
+
+ printf("ifunc\n");
+ clock_gettime(CLOCK_REALTIME_PRECISE, &start);
+ for (i=0; i<ROUNDS; i++)
+ A();
+ clock_gettime(CLOCK_REALTIME_PRECISE, &stop);
+ printf("time: %lld ns\n", stop.tv_nsec - start.tv_nsec);
+
+ printf("nop nop nop\n");
+ clock_gettime(CLOCK_REALTIME_PRECISE, &start);
+ for (i=0; i<ROUNDS; i++)
+ B();
+ clock_gettime(CLOCK_REALTIME_PRECISE, &stop);
+ printf("time: %lld ns\n", stop.tv_nsec - start.tv_nsec);
+
+ printf("long nop\n");
+ clock_gettime(CLOCK_REALTIME_PRECISE, &start);
+ for (i=0; i<ROUNDS; i++)
+ C();
+ clock_gettime(CLOCK_REALTIME_PRECISE, &stop);
+ printf("time: %lld ns\n", stop.tv_nsec - start.tv_nsec);
+
+ return (0);
+}
+
+void *__a (void)
+{
+ __asm __volatile ("push %%rax" ::: "memory");
+ __asm __volatile ("xor %%rax, %%rax" ::: "memory");
+ __asm __volatile ("pop %%rax" ::: "memory");
+}
+
+void *__b (void)
+{
+ printf("b\n");
+}
+
+static void (*disp_a (void)) (void)
+{
+ return 1 ? __a : __b;
+}
+
+void
+B(void)
+{
+ __asm __volatile ("push %%rax" ::: "memory");
+ __asm __volatile ("nop; nop; nop" ::: "memory");
+ __asm __volatile ("xor %%rax, %%rax" ::: "memory");
+ __asm __volatile ("pop %%rax" ::: "memory");
+}
+
+void
+C(void)
+{
+ __asm __volatile ("push %%rax" ::: "memory");
+ /* intel 3 byte nop */
+ __asm __volatile (".byte 0x0f,0x1f,0x00" ::: "memory");
+ __asm __volatile ("xor %%rax, %%rax" ::: "memory");
+ __asm __volatile ("pop %%rax" ::: "memory");
+}
More information about the svn-soc-all
mailing list