我从来没有在我的旧 linux 机器(都是 intel 32 位)上遇到过这个错误,所以我很茫然。
我正在尝试汇编和链接汇编代码(这非常简单并且应该可以工作)但是 ld
给出了错误
rs.o: In function `_start':
(.text+0x11): undefined reference to `eax'
有问题的行是 pushl %eax
行。我只需要将一个字节 0 压入堆栈,所以我决定使用异或 eax
寄存器。但是 pushb
在使用代码 pushb %al
并且如果我尝试使用 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
感谢任何帮助。
最佳答案
你的程序集有一个错误:$eax
应该是 %eax
in
movl $eax, %ebx #move socket fd to check echo $?
关于linux - ld:对 'eax' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12763230/