Is it possible to force code into a non-standard section?

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

Is it possible to force code into a non-standard section?

Jump to solution
692 Views
brunopaillard
Contributor III

Hi

Is it possible to use Processor Expert AND be able to force a few functions into a special memory area? I am facing the two following problems:

1)     I can create a new memory area using the "generate linker file" option of processor expert. I can also define the selected code to go into a special section using the "section" attribute, but I cannot find a way to allocate that section into the specified memory area while at the same time keeping the basic linker file created by Processor Expert. Is it possible to either add a special linker file to deal with just that code, or to modify the Processor Expert linker file in a way that won't be obliterated every time I regenerate the PE code?

2)     If the specified functions are not explicitly called by any module, they are not linked in to the executable, even if I use the "used" attribute. I would like to keep the "remove unused sections" option of the linker, but disable it just for these few functions. Is that possible?

Thanks

Bruno

0 Kudos
1 Solution
424 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Bruno.

About your questions:

1) The best way is to generate Processor Expert linker file the first time and then disable Linker file generation:

Linker_file.png

This way you can make all the changes you want without worrying about PEx overwriting the linker file. About code and variables relocation you can refer to the next document in the community and MCU on Eclipse blog:

Relocating Code and Data Using the CW GCC Linker File for Kinetis

Defining Variables at Absolute Addresses with gcc | MCU on Eclipse

2) Try using the linker KEEP command, e.g:

  .my_section :

  {

    . = ALIGN(4);

    KEEP(*(.my_section))

    . = ALIGN(4);

  } > m_mysection

Attached is a KDS v2.0.0 project for your reference.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
425 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Bruno.

About your questions:

1) The best way is to generate Processor Expert linker file the first time and then disable Linker file generation:

Linker_file.png

This way you can make all the changes you want without worrying about PEx overwriting the linker file. About code and variables relocation you can refer to the next document in the community and MCU on Eclipse blog:

Relocating Code and Data Using the CW GCC Linker File for Kinetis

Defining Variables at Absolute Addresses with gcc | MCU on Eclipse

2) Try using the linker KEEP command, e.g:

  .my_section :

  {

    . = ALIGN(4);

    KEEP(*(.my_section))

    . = ALIGN(4);

  } > m_mysection

Attached is a KDS v2.0.0 project for your reference.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
424 Views
brunopaillard
Contributor III

Hi Jorge

Thank you for your help

Solutions 1) and 2) work!

Regards

Bruno

0 Kudos