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. |
