IAR的ILINK鏈接器icf配置文件(分析MKE18F512xxx16_flash.icf)

本篇介紹介紹IAR的icf配置文件,以MKE18F512xxx16_flash.icf爲例子。
1.
我直接在.icf裏進行註解。

MKE18F512xxx16_flash.icf

//define [ exported ] symbol name = expr;
//作用:指定某個符號的值。
define symbol __ram_vector_table_size__ =  isdefinedsymbol(__ram_vector_table__) ? 0x00000400 : 0;
define symbol __ram_vector_table_offset__ =  isdefinedsymbol(__ram_vector_table__) ? 0x000003FF : 0;

define symbol m_interrupts_start       = 0x00000000;
define symbol m_interrupts_end         = 0x000003FF;

define symbol m_flash_config_start     = 0x00000400;
define symbol m_flash_config_end       = 0x0000040F;

define symbol m_text_start             = 0x00000410;
define symbol m_text_end               = 0x0007FFFF;

define symbol m_interrupts_ram_start   = 0x1FFF8000;
define symbol m_interrupts_ram_end     = 0x1FFF8000 + __ram_vector_table_offset__;

define symbol m_data_start             = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_data_end               = 0x1FFFFFFF;

define symbol m_data_2_start           = 0x20000000;
define symbol m_data_2_end             = 0x20007FFF;

/* Sizes */
if (isdefinedsymbol(__stack_size__)) {
  define symbol __size_cstack__        = __stack_size__;
} else {
  define symbol __size_cstack__        = 0x0400;
}

if (isdefinedsymbol(__heap_size__)) {
  define symbol __size_heap__          = __heap_size__;
} else {
  define symbol __size_heap__          = 0x0400;
}

define exported symbol __VECTOR_TABLE  = m_interrupts_start;
define exported symbol __VECTOR_RAM    = isdefinedsymbol(__ram_vector_table__) ? m_interrupts_ram_start : m_interrupts_start;
define exported symbol __RAM_VECTOR_TABLE_SIZE = __ram_vector_table_size__;

//define memory name with size = expr [, unit-size];
//作用:定義一個可編址的存儲地址空間(memory)。
define memory mem with size = 4G;


//define region name = region-expr;
//作用:定義一個存儲地址區域(region)。一個區域可由一個或多個範圍組成,每個範圍內地址必須連續,但幾個範圍之間不必是連續的。
define region m_flash_config_region = mem:[from m_flash_config_start to m_flash_config_end];
define region TEXT_region = mem:[from m_interrupts_start to m_interrupts_end]
                          | mem:[from m_text_start to m_text_end];
define region DATA_region = mem:[from m_data_start to m_data_end]
                          | mem:[from m_data_2_start to m_data_2_end-__size_cstack__];
define region CSTACK_region = mem:[from m_data_2_end-__size_cstack__+1 to m_data_2_end];
define region m_interrupts_ram_region = mem:[from m_interrupts_ram_start to m_interrupts_ram_end];

//define block name [ with param, param... ] 
{ 
extended-selectors 
}; 
//作用:     定義一個地址塊(block);它可以是個只保留指定大小的地址空間的空塊,比如棧、堆;也可以包含一系列的sections,由extended-selectors 選擇。 
//alignment = expr   (最小對齊字節數) 
//size = expr       (塊的大小)
define block CSTACK    with alignment = 8, size = __size_cstack__   { };
define block HEAP      with alignment = 8, size = __size_heap__     { };
define block RW        { readwrite };
define block ZI        { zi };

//initialize { by copy | manually } [ with param, param... ] 
{ 
section-selectors 
}; 
//作用: 初始化sections 
//by copy : 在程序啓動時自動執行初始化 
initialize by copy { readwrite, section .textrw };

//do not initialize 
{ 
section-selectors 
}; 
//作用: 規定在程序啓動時不需要初始化的sections;一般用於__no_init 聲明的變量段(.noinit) 
do not initialize  { section .noinit };

//place at { address memory [:expr] | start of region_expr | end of region_expr } 
{ 
extended-selectors 
}; 
//作用: 把section 或 block 放置在某個具體的起始地址處,或者一個 region 的開始或結束處 
place at address mem: m_interrupts_start    { readonly section .intvec };


//place in region-expr 
{ 
extended-selectors 
}; 
//作用:把section 或 block  (按任意順序)放置在某個region 中 
place in m_flash_config_region              { section FlashConfig };
place in TEXT_region                        { readonly };
place in DATA_region                        { block RW };
place in DATA_region                        { block ZI };
place in DATA_region                        { last block HEAP };
place in CSTACK_region                      { block CSTACK };
place in m_interrupts_ram_region            { section m_interrupts_ram };

2.
上文的readwrite,zi, section .intvec,section .textrw, section .noinit 等在哪兒定義呢?

其實這是系統預定義的這裏寫圖片描述

3.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章