问题
I am trying to convert .c files for ARM (ARMv7l for Raspberry Pi2) but I could not find any online converter or understand how it works. Previously these .c files were executable in Windows platform and thus unable to execute on Pi's arm architecture. Does anybody can assist me in this?
回答1:
Any c compiler can generate assembly code from C code, if your objective is specifically to generate assembly code for arm then you'll need a cross compiler such as the GNU arm embedded toolchain.
For gcc on particular you just need to use the -S
option when compiling, so the line looks something like:
gcc -S -source.c -o output.s
Of course you'll need to include any headers and include directories for it to compile.
if you simply want to cross compile it, then simply do the full compilation assemblage and linking process. Depending on how low level the c code is it's actually possible for it not to work on the pi 2 (but it will compile)
来源:https://stackoverflow.com/questions/44275519/converting-c-source-to-arm-assembly