【发布时间】:2011-05-16 09:25:05
【问题描述】:
我正在尝试在我的 Mac 上进行一些 x86 汇编编程,但无法生成可执行文件。问题似乎出在链接阶段。
helloWorld.s:
.data
HelloWorldString:
.ascii "Hello World\n"
.text
.globl _start
_start:
# load all the arguments for write()
movl $4, %eax
movl $1, %ebx
movl $HelloWorldString, %ecx
movl $12, %edx
# raises software interrupt to call write()
int $0x80
# call exit()
movl $1, %eax
movl $0, %ebx
int $0x80
组装程序:
as -o helloWorld.o helloWorld.s
链接目标文件:
ld -o helloWorld helloWorld.o
此时我得到的错误是:
ld: could not find entry point "start" (perhaps missing crt1.o) for inferred architecture x86_64
任何关于我做错/遗漏的建议都会非常有帮助。谢谢
【问题讨论】:
-
我知道我来晚了,但您需要将
_start更改为start。