最近我一直在研究自动生成的 STM32 项目中使用的链接器脚本,我对堆栈和堆内存段的定义有点困惑。
例如,我一直在查看 ST 的“CubeMX”固件包中为其 F0 系列芯片提供的文件,这些芯片具有 ARM Cortex-M0 内核。如果文件的许可证允许,我会粘贴整个脚本,但如果您好奇,可以从 ST 免费下载整个程序包1。无论如何,以下是与我的问题相关的部分:
/* Highest address of the user mode stack */
_estack = 0x20001000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
<...>
SECTIONS {
<...>
.bss :
{
<...>
} >RAM
/* User_heap_stack section, used to check …Run Code Online (Sandbox Code Playgroud)