test.h
struct test_desc {
const char *name;
}
#define PFM_TEST(a,name) struct test_desc a \
__attribute__((section("test"))) = {name}
test.c
PFM_TEST(name1,abc);
PFM_TEST(name2,dec);
main.c
#pragma section = "test"
void main(void)
{
struct struct test_desc *start,*stop;
start = (struct test_desc *)__section_begin("test");
stop = (struct test_desc *)__section_end("test");
printf("start->name = %s\n",start->name);
}
test.icf
define symbol __ICFEDIT_region_TEST_start__ = (0x10080000);
define symbol __ICFEDIT_region_TEST_end__ = (0x100DFFFF);
define region TEST_region = mem:[from __ICFEDIT_region_TEST_start__ to __ICFEDIT_region_TEST_end__];
keep { section test};
place at start of TEST_region {readwrite,section test};
actual result
hard fault patch...
expect result
start->name = abc
i can read the test section start address and stop address,i think i could cast them as test_desc type. but the actual result is error. i think maybe i can't put the section into the .data,how can i do that?
Finally, i set the section next to the .data section.like this
define block .ram_image2.data with fixed order{ section .data*,
section DATA,
section test*,
section .iar.init_table,
section __DLIB_PERTHREAD,
block CPP_INIT,
};
expect result i can get,and the param is not the const type.