测试.h
struct test_desc {
const char *name;
}
#define PFM_TEST(a,name) struct test_desc a \
__attribute__((section("test"))) = {name}
测试.c
PFM_TEST(name1,abc);
PFM_TEST(name2,dec);
主程序
#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);
}
测试.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};
实际结果
hard fault patch...
期待结果
start->name = abc
我可以读取测试部分的起始地址和停止地址,我想我可以将它们转换为 test_desc 类型。但实际结果是错误的。我想也许我不能将该部分放入.data,我该怎么做?