STM32堆栈
1.堆和栈大小 定义大小在startup_stm32f2xx.sStack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o>Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>Heap_Size EQU 0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
2.堆和栈位置通过MAP文件可知 HEAP 0x200106f8 Section 512startup_stm32f2xx.o(HEAP)
STACK 0x200108f8 Section 1024startup_stm32f2xx.o(STACK) __heap_base 0x200106f8 Data 0startup_stm32f2xx.o(HEAP)
__heap_limit 0x200108f8 Data 0startup_stm32f2xx.o(HEAP)
__initial_sp 0x20010cf8 Data 0startup_stm32f2xx.o(STACK)
显然 Cortex-m3资料可知:__initial_sp是堆栈指针,它就是FLASH的0x8000000地址前面4个字节(它根据堆栈大小,由编译器自动生成)显然堆和栈是相邻的。http://my.csdn.net/uploads/201205/19/1337414322_6402.gif
3.堆和栈空间分配栈:向低地址扩展堆:向高地址扩展显然如果依次定义变量先定义的栈变量的内存地址比后定义的栈变量的内存地址要大先定义的堆变量的内存地址比后定义的堆变量的内存地址要小 4.堆和栈变量栈:临时变量,退出该作用域就会自动释放堆:malloc变量,通过free函数释放
另外:堆栈溢出,编译不会提示,需要注意
好深奥的样子:lol
页:
[1]