assemblyx86armclang

Cross compile arm assembly for x86


I have an ARM assembly file (test.s) on a linux x86 computer.

I would like to compile and run this file on the linux box, but I'm not sure how.

Do I need to use clang? If so, what is the command?


Solution

  • It's highly unlikely that clang is going to help you in any way. Clang is a C/C++ compiler after all.

    What you need is an assembly translator. Such things do exist, but when open source projects are concerned, the quality is rather varying, so you should just google it and see for yourself.

    LLVM (the machine abstraction library below clang) had been used to do such things. Using LLVM is not different from using any other assembly translator: first you map your arm assembly to LLVM assembly, then you can compile LLVM assembly into something else.

    An example of such project is outlined here: http://infoscience.epfl.ch/record/149975/files/x86-llvm-translator-chipounov_2.pdf. This team was using a specially patched QEMU to produce intermediate LLVM code for them.

    In most such cases, it is easier (and safer) to simply rewrite the assembly by hand, possibly into higher level language.

    If the assembly file in question is a stand-alone program, you may not need to translate it at all. Simply try QEMU (http://www.qemu.org).