I am using CodeWarrior for StarCore 10.2.10. I wanted to place a part of my code in a new section. The CodeWarrior help tells me:
"The new section attribute lets you place a data object or a function in a specific section. The syntax is: __attribute__((section("section_name"))), where section_name specifies the target section's name.
The target section can be:
If the target section is a previously undefined section, the compiler creates a new section, and the section type depends on the current context."
Here is my code:
int main(void)
{
return 1;
}
int test(void) __attribute__ ((section (".my_section")));
int test(void)
{
return 1;
}
When I examined the generated binary using 'readelf', I could not find any section called '.my_section'. Do I need to do anything else?
Hello
Did you check the content of the .eld or the content of the .eln file with readelf?
If you checked the content of the .eld, the function that are nor used in the application are stripped
out from the executable file by the linker.
Can you give it a try by changing the following:
- invoke function test inside of main
- place a #pragma noinline in the beginning of function test to prevent any inlining of the function inside of main.
Is it working better?
CrasyCat