1.I create a custom section for myTest in .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__];
place at start of TEST_region {section .test_cases_entries};
2.I code some test in test.c
#pragma section = ".test_cases_entries"
void pfm_test_cases_init(void)
{
struct pwb_altest_desc *start,*stop;
start = __section_begin(".test_cases_entries");
stop = __section_end(".test_cases_entries");
printf("test section start = %x \n\r",start);
printf("test section end = %x \n\r",stop);
}
- result the response
test section start = 0
test section end = 0
- expect result: start of section 0x10080000? end of section 0x100DFFFF?
__section_begin(".section")
and__section_end(".section")
will be 0 if no part of the section.section
is included in the final binary. In your case you first must ensure that the section.test_case_entries
is not empty, i.e some module in you project put data in this section. Then you need to make the linker include this data in the final binary. This is either done by making a reference to the data in some module (__section_begin
and__section_end
does not count), declare the data as__root
, or by using--keep
on the linker command line.An test program that works on my machine is included below. Note that the .icf file is not complete as most of it depends on your target system.
test.c:
Part of test.icf