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

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

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

跳至解决方案
708 次查看
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 项奖励
1 解答
440 次查看
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 项奖励
2 回复数
441 次查看
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 项奖励
440 次查看
brunopaillard
Contributor III

Hi Jorge

Thank you for your help

Solutions 1) and 2) work!

Regards

Bruno

0 项奖励