Skip to content

Instantly share code, notes, and snippets.

@jjelinek
Created February 3, 2015 17:36
Show Gist options
  • Save jjelinek/9722817c1b00c9ee12e4 to your computer and use it in GitHub Desktop.
Save jjelinek/9722817c1b00c9ee12e4 to your computer and use it in GitHub Desktop.
vsyscall
#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int (*gettod)(int *) = (void *)0xffffffffff600000;
static void
vsyscall()
{
char buf[256];
int now, rval;
rval = gettod(&now);
snprintf(buf, sizeof (buf), "result of gettod is %d\n", now);
write(1, buf, strlen(buf) + 1);
}
int
main(int argc, char **argv)
{
struct sigaction act;
(void) sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
act.sa_handler = NULL;
if (sigaction(SIGSEGV, &act, NULL) != 0) {
perror("sigaction");
exit(EXIT_FAILURE);
}
vsyscall();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment