pau*_*ulr 5 macos assembly arm gnu compilation
我在 Mac Os X 上编译 .s ARM 程序集文件时遇到问题。我的 .s 文件是这样的:
mov r0, r1
Run Code Online (Sandbox Code Playgroud)
只是为了看看它是否有效。但是当我这样做时,我会
arm-elf-as my.s
得到一个
a.out文件。我有
chmod +x a.out
,
./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
Run Code Online (Sandbox Code Playgroud)
您将无法运行任何东西,因为为此您需要一个运行时系统和 ARM CPU。-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk例如,您可以使用或类似的方法为 iPhoneOS 进行编译。
| 归档时间: |
|
| 查看次数: |
4288 次 |
| 最近记录: |