map文件是一个底层变成文件必须掌握的
IAR的map文件分为以下几个部分(以下的所引用的map内容)
一、RUNTIME MODEL ATTRIBUTES
CppFlavor = * __Heap_Handler = Basic __SystemLibrary = DLib __dlib_dynamic_initialization = normal
二、PLACEMENT SUMMARY
各section在存储器中的分配
"A1": place at 0x08000000 { ro section .intvec };
"P1": place in [from 0x08000000 to 0x080fffff] { ro };
"P2": place in [from 0x20000000 to 0x2001ffff] { rw, block CSTACK, block HEAP };
- A1, FLASH空间,存放ro section和 .intvec
- P1, FLASH空间,存放ro data
- P2, sram空间,存放rw data, CSTACK, HEAP
如上图:
- A1里放的是.intvec,也就是复位向量表
- P1里放的是可执行代码和一些只读的数据
- P2第一部分存放.data,已经初始化的静态和全局变量
- P2第二部分存放.bss,未初始化的静态和全局变量
- P3第三部分存放CSTACK=0x4000和HEAP=0x1000.
系统SP的起始地址为CSTACK的结束地址, cortex的堆栈向下生长,每次入栈都会消耗8个word(32字节)的SRAM空间
堆栈大小设置如下图所示
三、INIT TABLE
显示与初始化有关的section tables
四、MODULE SUMMARY
显示所有被连接的文件信息,包括目标文件和库文件等
五、ENTRY LIST
给出了所有函数的入口地址,大小,类型
六、目标代码占用ROM和RAM
map文件的最后会给出目标代码占用的ROM和RAM空间大小
48 598 bytes of readonly code memory 80 703 bytes of readonly data memory 62 395 bytes of readwrite data memory
readonly code和readonly data使用的是ROM空间
readwrite data使用的是SRAM空间
附录:IAR Section 说明
Section | Description |
---|---|
.bss | Holds zero-initialized static and global variables. |
CSTACK | Holds the stack used by programs. |
.data | Holds static and global initialized variables. |
.data_init | Holds initial values for .data sections when the linker directive initialize by copy is used. |
DLIB_PERTHREAD | Holds variables that contain static states for DLIB modules. |
.exc.text | Holds exception-related code. |
HEAP | Holds the heap used for dynamically allocated data. |
.iar.dynexit | Holds the atexit table. |
.init_array | Holds a table of dynamic initialization functions. |
.intvec | Holds the reset vector table |
IRQ_STACK | Holds the stack for interrupt requests, IRQ, and exceptions. |
.noinit | Holds _ _no_init static and global variables. |
.preinit_array | Holds a table of dynamic initialization functions. |
.prepreinit_array | Holds a table of dynamic initialization functions. |
.rodata | Holds constant data. |
.text | Holds the program code. |
.textrw | Holds _ _ramfunc declared program code. |
.textrw_init | Holds initializers for the .textrw declared section. |