【发布时间】:2018-08-17 10:23:39
【问题描述】:
我目前正在学习 X86_Intel 64 位汇编,我想在 macOS 上运行我的汇编代码。我的代码在 Ubuntu VM 上正确编译和链接:
yasm -f elf64 -g dwarf2 -l div.lst div.asm
ld -o div div.o
但是,当我使用上述相同的命令时,我在 macOS 上遇到了问题。有什么明显我遗漏的东西吗?
Jonathans-MacBook-Pro:Practical 2 jonathancopeland$ yasm --version
yasm 1.3.0
Compiled on Sep 15 2017.Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
Run yasm --license for licensing overview and summary.
Jonathans-MacBook-Pro:Practical 2 jonathancopeland$ yasm -f elf64 -g dwarf2 -l div.lst div.asm
Jonathans-MacBook-Pro:Practical 2 jonathancopeland$ ld -o div div.o
**ld: warning: -arch not specified
ld: warning: -macosx_version_min not specified, assuming 10.11ld: warning: ignoring file div.o, file was built for unsupportedfile format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): div.o
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for inferred architecture x86_64
Jonathans-MacBook-Pro:Practical 2 jonathancopeland$**
Here is a screenshot of my code, file structure and terminal
【问题讨论】:
-
函数名称在 macOS 上用前导下划线修饰。另外,请勿发布代码图片。始终将代码作为文本发布!请更新您的帖子以将您的所有代码粘贴到问题中。一旦你这样做,我就会撤回我的反对票。
-
OS X 使用
macho64,而不是elf64。 -
所以你在 VM 中运行 Mac OS X? (那么关于 Ubuntu 的信息并不真正相关,只会在 VM 本身中遇到一些奇怪的错误)。您是否在 Mac OS 上的 VM 中运行 Ubuntu? (那么关于 Mac 的信息是不相关的,因为你在 VM 中的代码将在 linux 上运行,而不是在 mac 上)。通过快速阅读问题,我不清楚你想要实现什么以及你想要实现的目标。
标签: macos assembly x86-64 yasm