将C源代码转换为ARM程序集 [英] Converting C source to ARM assembly

查看:431
本文介绍了将C源代码转换为ARM程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将.c文件转换为ARM(对于Raspberry Pi2为ARMv7l),但是我找不到任何在线转换器,也无法理解其工作原理.以前,这些.c文件可在Windows平台上执行,因此无法在Pi的arm架构上执行.有人可以帮我吗?

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?

推荐答案

任何c编译器都可以从C代码生成汇编代码,如果您的目标是专门为arm生成汇编代码,那么您将需要一个交叉编译器,例如 GNU手臂嵌入式工具链.

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.

特别是对于gcc,您只需要在编译时使用-S选项,因此该行应类似于:

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.

如果您只是想交叉编译它,那么只需执行完整的编译组装和链接过程即可.实际上,取决于c代码的底层级别,它可能无法在pi 2上运行(但会编译)

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)

这篇关于将C源代码转换为ARM程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆