Compiling ARM .s file on Mac

ぃ、小莉子 提交于 2019-12-04 09:53:08

You're assembling it allright, you just can't run it on a Mac since Macs don't have ARM CPUs. If you install Xcode with iOS support, you can compile ARM code:

# 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

You won't be able to run anything, because for that you'll need a runtime system and and ARM CPU. You can use -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk or similar to compile for the iPhoneOS for example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!