Process command line in Linux 64 bit
This question already has an answer here:
 You are loading the correct address into %rcx .  
 int 0x80 then invokes the 32-bit syscall interface.  That truncates the address to 32 bits, which makes it incorrect.  (If you use a debugger and set a breakpoint just after the first int 0x80 , you will see that it returns with -14 in %eax , which is -EFAULT .)  
 The second syscall, exit , works OK because the truncation to 32 bits doesn't do any harm in that case.  
If you want to pass a 64-bit address to a system call, you will have to use the 64-bit syscall interface:
syscall , not int 0x80 ;  Here is a working version of your code:
.section .text
.globl _start
_start:
 movq  %rsp, %rbp
 movq $1, %rax
 movq $1, %rdi
 movq 8(%rbp), %rsi       # program name address ?
 movq $5, %rdx
 syscall
 movq $60, %rax
 movq $0, %rdi
 syscall
 As stated in the X86_64 ABI: Use the syscall instruction instead of int $0x80 .  The Kernel uses different registers in 64 Bit as syscall arguments, and the number assigned for a syscall function varies between i386 and x86_64, too.  
 An example - in german, sorry - can be found here:  
 http://zygentoma.de/codez/linux_assembler.php  
上一篇: 任何人都可以解释这汇编代码
下一篇: 在Linux 64位处理命令行
