在x86_64的Linux的内联汇编系统调用? [英] Syscall from inline asm in x86_64 Linux?
问题描述
为什么退出摆好我的程序的这个打印垃圾呢?我用的系统调用BSD这样了,我不知道我需要使它在Linux下正常工作。
INT
主(INT ARGC,字符** argv的)
{
__asm(MOVQ $ 1,RAX%; MOVQ $ 0%RDI;系统调用); / *退出(0)? * /
返回0;
}
感谢。
为什么这个打印垃圾,而不是正常退出我的程序呢?
块引用>CESA-2009-001 ,系统调用1退出在i386,但在x86_64写。
我会需要使它在Linux下正常工作
块引用>从当前的<一个使用系统调用序href=\"http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=blob;f=arch/x86/include/asm/unistd%5F64.h\"相对=nofollow> unistd_64.h
希望这有助于!
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.
解决方案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!
这篇关于在x86_64的Linux的内联汇编系统调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!