我正在尝试将一些变量放入特定的 ROM lication 中。
在链接器配置文件中:
define symbol __ICFEDIT_region_APP_ROM_start__ = 0x08070000 ;
define symbol __ICFEDIT_region_APP_ROM_end__ = 0x0807FFFF;
define region APP_ROM_region = mem:[from __ICFEDIT_region_APP_ROM_start__ to __ICFEDIT_region_APP_ROM_end__];
place in APP_ROM_region { readonly section test_data};
在源文件中:
#pragma default_variable_attributes = @ "test_data"
const U8 testVar8 = 0;
const U8 testArray512[512];
const uint32_t testVar32 = 0x1234ABCD;
const U8 testArray500[500];
#pragma default_variable_attributes =
生成的 .map 文件:
test_data const 0x08070000 0x200 source_file.o [1]
test_data const 0x08070200 0x1f4 source_file.o [1]
test_data const 0x080703f4 0x4 source_file.o [1]
test_data const 0x080703f8 0x1 source_file.o [1]
testArray512 0x08070000 0x200 Data Gb source_file.o [1]
testArray500 0x08070200 0x1f4 Data Gb source_file.o [1]
testVar32 0x080703f4 0x4 Data Gb source_file.o [1]
testVar8 0x080703f8 0x1 Data Gb source_file.o [1]
无论如何它都有效 - 变量位于正确的部分。
但是由于变量的大小,链接器已将其整理好。
有没有办法告诉链接器不要更改变量的顺序,所以它们会以与源文件中声明的顺序相同的顺序出现在映射文件中?
目标是:
testArray8 0x08070000 0x1 Data Gb source_file.o [1]
testArray512 0x08070001 0x200 Data Gb source_file.o [1]
testVar32 0x08070201 0x4 Data Gb source_file.o [1]
testVar500 0x08070205 0x1f4 Data Gb source_file.o [1]