我想打电话从32位汇编写系统调用,代码即时通讯现在使用:混合整数和字符串在strace的输出
.section .rodata # read-only data
msg:
.ascii "hello" # not null-terminated string called "msg"
len:
.long 5 # length of "msg"
.section .text # actual runnable code
.globl _start
.type _start, @function
_start:
movl $4, %eax # syscall number into eax (4 is write)
movl $1, %ebx # argument number 1 into ebx (stdout)
movl $msg, %ecx # argument number 2 into ecx
movl len, %edx # argument number 3 into edx
int $0x80
movl $1, %eax # syscall number into eax (1 is exit)
movl $0, %ebx # argument number 1 into ebx (exit code)
int $0x80
它编译并运行正常,打印字符串“你好”到控制台,但是当我使用strace的‘看’写发生时,我得到以下的输出:
execve("./main", ["./main"], [/* 86 vars */]) = 0
strace: [ Process PID=22529 runs in 32 bit mode. ]
write(1, "hello", 5hello) = 5
exit(0) = ?
+++ exited with 0 +++
我想知道是什么原因导致第三arugment被5hello而不是5
没有什么,'你好'在那里是你的程序的实际输出。重定向strace或你的代码的输出,所以他们不会穿插。 – Jester