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 | |
.prepreinit_array | |
.rodata | Holds constant data. |
.text | Holds the program code. |
.textrw | Holds _ _ramfunc declared program code. |
.textrw_init | Holds initializers for the .textrw declared section. |