Skip to content

Instantly share code, notes, and snippets.

@chrepl
Last active October 14, 2018 15:36
Show Gist options
  • Save chrepl/682adaf22e84b4c2a82f48293acad51d to your computer and use it in GitHub Desktop.
Save chrepl/682adaf22e84b4c2a82f48293acad51d to your computer and use it in GitHub Desktop.
int recursive();
int main()
{
puts("call recursive()");
asm (
"call _recursive"
);
// never reached
return 0;
}
asm (
".intel_syntax noprefix \n"
"_recursive: \n"
// " push rbp \n" // uncomment this to get an segfault
" mov rbp, rsp \n"
" jmp _recursive \n" // jmp not call - call saves ret to stack - change jmp to call will get an segfault to
" xor eax, eax \n" // never reached
" pop rbp \n"
" ret \n" // if reached should segfault
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment