我從來沒有在我的舊的Linux機器上安裝這個錯誤(都是英特爾32位),所以我不知所措。ld:未定義引用'eax'
我想組裝和鏈接彙編代碼(這是非常簡單的,並應工作),但ld
是給錯誤
rs.o: In function `_start':
(.text+0x11): undefined reference to `eax'
有問題的行是pushl %eax
線。我只需要將一個0的單個字節推入堆棧,所以我決定使用寄存器xor'd eax
。但pushb
給了我一個「無效後綴或操作數推」錯誤而使用的代碼pushb %al
與as
組裝,如果我嘗試使用pushl %eax
as
組裝正常,但連接對我大喊大叫。
這裏是代碼。
.section .data
.section .text
.global _start
_start:
xorl %eax, %eax
#sys_socketcall(int call, __user *args)
#sys_socket(int domain, int type, int protocol)
pushl %eax #protocol: 0
pushl $1 #type: SOCK_STREAM
pushl $2 #domain: AF_INET
movL $1, %ebx #sys_socket
movl $102, %eax #sys_socketcall
int $0x80
movl $eax, %ebx #move socket fd to check echo $?
movl $1, %eax #exit
int $0x80
任何幫助表示讚賞。
''pushl%eax'在'_start + 0x11'處沒有辦法。 'movl $ eax,%ebx',另一方面...。 – DCoder