summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@mit.edu>2011-06-16 13:50:40 -0400
committerAndy Lutomirski <luto@mit.edu>2011-06-16 13:50:40 -0400
commit83310bdd6db1fbd54d581039b1570b8baa4f7f55 (patch)
tree796ad2e2b88931e3dcbda693995ddeb072133845
parent4e9447bf1aad5b35f099c1494d37d1fede184dfe (diff)
downloadmisc-tests-83310bdd6db1fbd54d581039b1570b8baa4f7f55.tar.gz
Add dump-vdso for real
-rw-r--r--Makefile5
-rw-r--r--dump-vdso.c21
2 files changed, 25 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 575630d..d68d939 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
.PHONY: all
-all: timing_test evil-clock-test test_vsyscall
+all: timing_test evil-clock-test test_vsyscall dump-vdso
timing_test: timing_test.cc
g++ -o $@ -lrt -ldl -O2 -Wall -g $^
@@ -9,3 +9,6 @@ evil-clock-test: evil-clock-test.cc
test_vsyscall: test_vsyscall.cc
g++ -o $@ -std=gnu++0x -lrt -ldl -O2 -Wall -g $^
+
+dump-vdso: dump-vdso.c
+ gcc -o $@ -ldl -O2 $^
diff --git a/dump-vdso.c b/dump-vdso.c
new file mode 100644
index 0000000..937c00c
--- /dev/null
+++ b/dump-vdso.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <string.h>
+
+int
+main()
+{
+ FILE *maps;
+ void *vdso_begin, *vdso_end;
+
+ maps = fopen("/proc/self/maps", "r");
+ char buf[1024];
+ while (fgets(buf, 1024, maps)) {
+ if (strstr(buf, "[vdso]")) break;
+ }
+ fclose(maps);
+
+ sscanf(buf, "%p-%p", &vdso_begin, &vdso_end);
+ write(1, vdso_begin, vdso_end - vdso_begin);
+
+ return 0;
+}