为什么 Cortex-M4 在链接描述文件中包含 ARM 到 Thumb 胶水

Why does a Cortex-M4 include ARM to Thumb glue in the linker script

我们正在为 STM32 芯片上的 ARM Cortex M4 编写一些代码。

我的理解是 Cortex-M4 有一些 32 位指令,但这些不是 32 位 ARM 指令,它们只是一些特殊指令。我认为粘合剂是用于在 ARM 和 thumb 指令集之间转换的。那么为什么链接描述文件需要胶水

.text :
{
. = ALIGN(4);
*(.text)           /* .text sections (code) */
*(.text*)          /* .text* sections (code) */
*(.glue_7)         /* glue arm to thumb code */
*(.glue_7t)        /* glue thumb to arm code */

我可以删除 glue_7 和 glue_7t 因为处理器只支持 thump 指令吗?这样做会释放任何闪存吗?

发布的脚本总是会为 ARM/thumb 代码调用 thumb/ARM 创建部分,如果没有可调用的部分,则这些部分是空的。空白部分是良性的。

如果您想在不修改链接器的情况下删除未使用的部分,一种干净的方法是执行死代码消除,通过--gc-sections:

Once the objects and static libraries are created with these options, the linker can perform the dead code elimination. You can do this by setting the -Wl,--gc-sections option to gcc command or in the -largs section of gnatmake. This will perform a garbage collection of code and data never referenced.