summaryrefslogtreecommitdiffstats
path: root/dump-vdso.c
blob: a4b6f63d50d1a97d2ac5b7022458e87726766e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main()
{
	FILE *maps;
	void *vdso_begin, *vdso_end;
	int found_vdso = 0;

	maps = fopen("/proc/self/maps", "r");
	char buf[1024];
	while (fgets(buf, 1024, maps)) {
		if (strstr(buf, "[vdso]")) {
			found_vdso = 1;
			break;
		}
	}
	fclose(maps);

	if (!found_vdso) {
		fprintf(stderr, "Could not find vdso mapping\n");
		return 1;
	}

	sscanf(buf, "%p-%p", &vdso_begin, &vdso_end);
	write(1, vdso_begin, vdso_end - vdso_begin);

	return 0;
}