例如,我想在0x10000000,0x100100000,0x100200000,.中放置一个特殊的数据.为此,我想在头文件中做,
#define DATA_START 0x100000000
#define DATA_GAP 0x100000
#define DATA0_START DATA_START + 0*DATA_GAP
#define DATA1_START DATA_START + 1*DATA_GAP
#define DATA2_START DATA_START + 2*DATA_GAP
现在,我想要有一个链接器脚本,并在那里定义部分,并想做一些类似的事情.(以便C程序和链接器脚本匹配).
. = DATA_START;
.mydata : {
*(.data0)
. = ALIGN(DATA_GAP);
*(.data1)
. = ALIGN(DATA_GAP);
...
}
of course with enough value for DATA_GAP so that data don't overlap.
But in linker script, the define statement is not "#define DATA_START 0x100000000" but "DATA_START = 0x100000000;". So if I want to use a single file to be used in C and linker script, how can I do it?? (I read somewhere that in programs there should be single point of truth, without having to fix data in multiple places..)
I know how to declare a variable in linker script and use it C program (using "var = ." in linker sciprt and using &var in C program..), but this time I want to statically allocate some data.