Skip to content

Instantly share code, notes, and snippets.

@XanClic
Created September 11, 2017 15:30
Show Gist options
  • Save XanClic/91250ab8d02eb24ecd726fe2c4ba27be to your computer and use it in GitHub Desktop.
Save XanClic/91250ab8d02eb24ecd726fe2c4ba27be to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <stdio.h>
#include <trampoline.h>
static void *i;
static int fn(void)
{
printf("%i\n", (int)(uintptr_t)i);
return 0;
}
int main(void)
{
int (*f)(void) = alloc_trampoline(fn, &i, (void *)42UL);
f();
return 0;
}
@XanClic
Copy link
Author

XanClic commented Sep 11, 2017

$ gcc trampoline.c -ltrampoline
$ ./a.out
42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment