macos - GAS 32 位程序集中的未定义符号错误
问题描述
我编写了一个名为“test.s”的 GAS 32 位源代码,如下所示:
.global _main
.data
message: .string "Hello, World!\n\0"
.text
_main:
# BEGIN Stack Frame
pushl %ebp
movl %esp, %ebp
# Call Unix System Call - write(fd, buf, count)
pushl $1 # fd = stdout
pushl $message # buf = message
pushl $14 # count = 14
call write
# END Stack Frame
movl %ebp, %esp
popl %ebp
xor %eax, %eax # return 0
ret
我在 macOS 10.14.4 (Mojave) 中运行如下命令:
$ gcc -m32 test.s -otest
然后出现错误:
ld: warning: The i386 architecture is deprecated for macOS (removed from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
"write", referenced from:
_main in test-8c5cf2.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
但具体是什么原因我也不知道...
解决方案
推荐阅读
- php - mail(): 无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置
- powerbi - 在 PowerBI 中同时对多个条形图和表格进行排序
- node.js - NodeJS表单没有正确提交数据
- r - 如何在R中传递变量的名称
- cross-compiling - 带有配置脚本的 Emscripten 说 `long long` 不可用
- javascript - Django ajax 我将如何更改我的代码以使用 ajax 来喜欢帖子而不刷新
- javascript - React 中的 Fancybox
- javascript - Angular-template 中的静态函数
- java - 单元测试 - 使用 MockMvc 使用带有 HashMap 的 @RequestHeader 测试控制器
- ios - 在 iOS 上使用 AVAudioPlayer 播放静音的最佳方式