问题描述
我在Mac上,正在尝试在X86程序集中将单个字符打印到stdout。我没有找到任何适用于我的示例-但是,这是最接近的示例。通过这样组装:gcc -masm=intel print.asm
,我得到以下输出:
Undefined symbols for architecture x86_64:
"putchar",referenced from:
_main in print-c2eebf.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)
这是我的clang版本:
Configured with: --prefix=/Library/Developer/CommandLinetools/usr --with-gxx-include-dir=/Library/Developer/CommandLinetools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLinetools/usr/bin
这是我的代码:
.global _main,putchar
.text
_main:
push 0x21 # put exclamation point on stack
call putchar
mov rdi,0 # exit code of zero
mov rax,0x2000001
syscall
这真令人沮丧,我不知道如何使其正常工作。有人有解决方案吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)