gcc链接器-将存档中的所有目标文件映射到特定部分 [英] gcc linker - map all object files in an archive to a certain section
问题描述
在gcc
链接器文件中,如何将存档中所有.obj
的所有功能映射到特定部分?
In a gcc
linker file, how do you map all functions of all .obj
s in an archive to a certain section?
我知道如何在源文件中按功能进行操作,但是我想在链接器文件中按.obj
名称进行操作.
I know how to do it function-by-function inside the source file but I'd like to do it in the linker file by .obj
name.
我在gcc邮件列表中找到了此帖子但对我来说,它不起作用.
I found this post in the gcc mailing lists but for me it's not working.
我通过复制海报的内容来修改了.ld
...
I modified my .ld
by copying what the poster did...
.dflash_code :
{
*archive.dlb: // this is my archive file
} >dflash
...但是没有用.
当我在函数中添加__attribute__((section(".dflash_code")))
时,链接器报告的溢出数量减少,因此我知道链接器正在注意__attribute__
.
When I add __attribute__((section(".dflash_code")))
to a function, amount of overflow the linker reports decreases so I know the linker is paying attention to the __attribute__
.
但是,我真的很想为整个存档(即.dlb
)这样做.
However, I'd really like to do it for an entire archive (that's the .dlb
).
我试图仅基于一个.obj
文件来执行此操作,即使这样也不起作用
I tried to do it just based on one .obj
file and even that doesn't work
.dflash_code :
{
*compile.doj //my object file
} >dflash
更新
实际上,它似乎正在工作(有点):它将 .text 部分的ATI_micropython.dlb
内容输出到.dflash_code
除了.
Actually, looks like it is working (kinda): it is outputting the contents of ATI_micropython.dlb
to .dflash_code
except for the .text sections.
推荐答案
我尝试的语法是正确的.
问题是我的链接器文件中有一个 SECTION 语句上方,下面的 SECTION 语句
The syntax I tried was correct.
The problem was that in my linker file, I had a SECTION statement above the following SECTION statement
.dflash_code :
{
*archive.dlb: // this is my archive file
} >dflash
将所有*.text
部分放置在一个已满的部分中.
that put all *.text
sections in a section that was getting overfull.
即使在这种错误情况下,链接器也会产生一个.map
,并检查该.map
,表明archive.dlb
内除.text 之外的所有对象部分都已放置在目标位置.dflash_code
.
Even in this errored condition, the linker produced a .map
and examining this .map
showed that all sections of the objects inside archive.dlb
except for .text were being placed in the intended .dflash_code
.
我将.dflash_code
部分移到了引用*.text
的部分上方,现在可以使用了.
I moved the .dflash_code
section above the portion that was referencing *.text
and it now works.
这篇关于gcc链接器-将存档中的所有目标文件映射到特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!