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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

525 Views
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?

Labels (1)
0 Kudos
1 Reply

328 Views
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 Kudos