Syscall from inline asm in x86_64 Linux?
assembly, c, inline-assembly, linux, x86-64
Solution
Why does this print garbage instead of exiting my program gracefully?
Per CESA-2009-001, "Syscall 1 is exit on i386 but write on x86_64".
what would I need to make it work in Linux
Use the syscall ordinals from the current unistd_64.h
Hope this helps!
Problem
Why does this print garbage instead of exiting my program gracefully? I use system calls this way on BSD, and I wonder what would I need to make it work in Linux. ``` int main(int argc, char **argv) { __asm ("movq $1,%rax; movq $0,%rdi; syscall"); /* exit(0) ? */ return 0; } ``` Thanks.