Skip to content

Instantly share code, notes, and snippets.

@metanest
Created October 28, 2019 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metanest/82bc88feb73bbb297a5b77b81ad2c69c to your computer and use it in GitHub Desktop.
Save metanest/82bc88feb73bbb297a5b77b81ad2c69c to your computer and use it in GitHub Desktop.
#include <sys/types.h>
ssize_t __sys_write(int, const void *, size_t);
void __sys_exit(int);
void hoge_start(void) {
char const msg[] = "hello\n";
void **user_stack_ptr = __builtin_frame_address(0);
*(user_stack_ptr--) = &&cont1;
goto hello; __builtin_unreachable();
cont1:
*(user_stack_ptr--) = &&cont2;
goto hello; __builtin_unreachable();
cont2:
__sys_exit(0); __builtin_unreachable();
hello:
__sys_write(1, msg, sizeof(msg)-1);
goto **(++user_stack_ptr);
__builtin_unreachable();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment