STM32 CubeIDE Place a static library in specified memory region and mapped to the absolute memory address

huangapple go评论67阅读模式
英文:

STM32 CubeIDE Place a static library in specified memory region and mapped to the absolute memory address

问题

我有一个STM32 CubeIDE项目。
我想将一个静态库放置在内部闪存的绝对内存地址的上部,而应用程序代码将放置在闪存的开头。
但库的内容分配在与应用程序代码相同的文本区域下。

我在链接器脚本中这样做:

MEMORY
{
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 244K
LIB_region (rx) : ORIGIN = 0x0803D000, LENGTH = 4K
RAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
RAM2 (xrw) : ORIGIN = 0x20009000, LENGTH = 28K
}
...
my_lib_section :
{
*(libTestLib.a)
} > LIB_region

英文:

I have an STM32 CubeIDE project.
I want to place a static library in an absolute memory address in the upper part of the internal flash while the application code will be placed at the beginning of the flash.
But the content of the library is allocated under the text region with the application code

I did this in the linker script:

MEMORY
{
  ROM    (rx)    			: ORIGIN = 0x08000000, LENGTH = 244K
  LIB_region (rx)			: ORIGIN = 0x0803D000, LENGTH = 4K 
  RAM1   (xrw)   			: ORIGIN = 0x20000000, LENGTH = 32K
  RAM2   (xrw)   			: ORIGIN = 0x20009000, LENGTH = 28K
}
...
my_lib_section : 
{
    *(libTestLib.a)
} > LIB_region

答案1

得分: 1

你可以使用以下语法来包含文件的所有部分:

my_lib_section : 
{
    libTestLib.a
} > LIB_region

请参阅GNU链接器命令语言手册的section placement部分:

filename

您可以简单地指定要放置在当前输出部分的特定输入文件;来自该文件的所有部分都将放置在当前部分定义中。

如果您只想要从库中的 .text 部分,可以使用以下方式:

my_lib_section : 
{
    libTestLib.a (*.text)
} > LIB_region
英文:

You should be able to include all the sections of a file using the following syntax:

my_lib_section : 
{
    libTestLib.a
} > LIB_region

See the section placement section of the GNU linker command language manual:

> filename
>
>You may simply name a particular input file to be placed in the current output section; all sections from that file are placed in the current section definition.

If you just wanted the .text section from the library, this should work:

my_lib_section : 
{
    libTestLib.a (*.text)
} > LIB_region

huangapple
  • 本文由 发表于 2023年8月5日 00:02:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定