Adding new section to generated .ELD executable (CodeWarrior for StarCore)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Adding new section to generated .ELD executable (CodeWarrior for StarCore)

949 次查看
debarati
Contributor I

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:

 

  • a basic section, such as data, program, bss, rom, or init section

 

  • a custom section, defined in the application file

 

  • a previously undefined section

 

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?

标签 (1)
0 项奖励
回复
1 回复

752 次查看
CrasyCat
Specialist III

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

0 项奖励
回复