gcc - 仅编译thumb1

标签 gcc compiler-construction arm thumb

如何告诉 gcc 编译为仅 Thumb1 指令?

每个人都知道 helloworld.c:

#include <stdio.h>  
main() {  
 printf("Hello world");  
}  

这是我的命令行:

user@debian-armel:~$gcc -mcpu=cortex-m3 -mthumb helloworld.c && objdump -d a.out

瞧:大多数指令都是 32 位宽,而不是我预期的 16 位宽。

那么,我做错了什么?

最佳答案

Cortex-M3 支持 Thumb-2,因此编译器可以自由生成 32 位版本。以下之一应该可以满足您的需求:

-march=ARMv5 -mthumb
-march=ARMv4T -mthumb
-march=ARMv6-M
-mcpu=Cortex-M0

关于gcc - 仅编译thumb1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13474322/

相关文章:

linux - tcl - 检测 x11 是在 ARM 还是 x86 上运行

c++ - makefile 为不同的体系结构设置不同的链接器标志

c - 为什么 malloc 向 sbrk 请求不合理的内存量。什么可以阻止它?

c编译器错误链接

c - 在 ARM7TDMI 上获取参数地址时 GCC 是否损坏?

arm - AOSP Build TARGET_PRODUCT 失败

c - 这个 c 程序在 windows 中工作正常但在 Linux 中不工作

linux - 编译器版本

optimization - 人工智能编译器

c++ - 错误 : expected constructor, 析构函数,或 ';' token 之前的类型转换?