How to compile ARM assembly in ARM syntax with Clang?

5.3k Views Asked by At

It seems that by default Clang assumes GNU assembler syntax.

How to compile with Clang an assembly file using ARM syntax as this (directives) and this (instructions)?

1

There are 1 best solutions below

1
On

Assembly language is defined by the assembler the program that parses the file and makes machine code from it. As we all know turbo assembler, microsoft assembler, nasm and gnu assembler for the x86 dont conform to the same language. No reason to assume any other assembler conforms to anyone elses assembly language. You should never use links like that in a question, see how to ask questions, but if you want to use ARM syntax you have to use one of the ARM assemblers, which can get pricy. If you want gnu syntax you use gnu and some other you use some other. Likewise the author of a C compiler should or often does desire to conform the input to the C standard which is not something defined by the compiler but by a standards body. The output of that compiler doesnt have to conform to any standard other than the one created by that compiler, they can choose machine code in some object format or they can as they often do choose some assembly language in whatever assembler's format they want. No reason to expect them to support multiple assemblers. So then you obviously combine tools into a chain, a compiler chains to an assembler and those outputs chain into the linker. If a particular llvm tool chooses to or only supports one assembly language as defined by one assembler there is no reason to expect them to support some other. if they support others well maybe you can just use the right command line option. The llvm tools as are the gnu are open source, you are welcome at any time to change whatever you want to suit your needs.