【发布时间】:2012-10-06 19:46:05
【问题描述】:
我在我的旧 linux 机器(都是 intel 32bit)上从来没有遇到过这个错误,所以我很茫然。
我正在尝试汇编和链接汇编代码(这非常简单并且应该可以工作)但是ld 给出了错误
rs.o: In function `_start':
(.text+0x11): undefined reference to `eax'
有问题的行是pushl %eax 行。我只需要将 0 的单个字节推入堆栈,因此我决定使用 xor'd eax 寄存器。但是pushb 在使用代码pushb %al 与as 组装时给我一个“invalid suffix or operands for push”错误,如果我尝试使用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,另一方面....