我使用的是 Mac Os X,但在编译 .s ARM 汇编文件时遇到问题。
我的 .s 文件是这样的:
mov r0, r1
只是看看它是否有效。
但当我这样做时arm-elf-as my.s
我得到一个a.out
文件。
我愿意chmod +x a.out
and
./a.out
但它说cannot execute binary file
这让我很困惑,因为如果我用arm-elf-as编译它,它应该能够执行。我该如何编译这个.s?
你已经组装好了,只是不能在 Mac 上运行它,因为 Mac 没有 ARM CPU。如果您安装了支持 iOS 的 Xcode,则可以编译 ARM 代码:
# the file
$ cat foo.s
mov r0, r1
# compile with llvm-gcc
$ /Developer/Platforms/iPhoneOS.platform/usr/bin/llvm-gcc-4.2 -arch armv6 -c foo.s
# resulting file is ARM object file
$ file foo.o
foo.o: Mach-O object arm
# and you can disassemble it
$ otool -v -t foo.o
foo.o:
(__TEXT,__text) section
00000000 e1a00001 mov r0, r1
您将无法运行任何东西,因为为此您需要一个运行时系统和 ARM CPU。您可以使用-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk
或者类似于 iPhoneOS 的编译。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)