如何列出链接器分配的代码对象w / gcc? [英] How to list linker allocated code objects w/ gcc?
问题描述
我正在构建一个由多个代码模块和一个静态库组成的嵌入式应用程序。一些全局变量明确地放置在专用内存段中(即,不是默认的.data段)。
处理器内存架构是4个bank,创建了一个连续的物理内存空间。在我的应用程序中,只有第一家银行是为代码保留的,其他三家银行是为显式分配的全局数据和一小堆栈保留的。 问题是代码部分(.text)现在超出了第一个银行边界,我收到以下链接器错误消息:
./ bin / ld :部分.data_bank1在[0000000000002000,0000000000003fff]加载部分重叠部分.text在[0000000000000630,00000000000020df]加载
./bin/ld:部分.fini加载在[00000000000020e0,00000000000020f9]重叠部分.data_bank1加载在[0000000000002000 ,0000000000003fff]
有没有办法看到对象分配(可能在临时对象文件中)链接器检查节和对象的重叠,并放弃构建?
您可以传递 - -print-map
标志到链接器。这将使它发出每个目标文件中每个部分映射到内存中的细节。
示例:
.text 0x0000000000400370 0x2c /<snip>/lib64/crt1.o
0x0000000000400370 _start
.text 0x000000000040039c 0x17 /<snip>/lib64/crti.o
* fill * 0x00000000004003b3 0xd 90909090
.text 0x00000000004003c0 0x92 /<snip>/4.6.3/crtbegin.o
* fill * 0x0000000000400452 0x2 90909090
.text 0x0000000000400454 0x21 / tmp / ccwAfGkH.o
0x000000000040045f x
0x000000000040046a y
0x0000000000400454 main
I am building an embedded application comprised of several code modules and a static library. Some global variables are explicitly placed in dedicated memory sections (i.e, not the default .data section).
The processor memory architecture is 4 banks, creating a contiguous physical memory space. In my application, only the 1st bank is reserved for code and the other 3 banks are reserved for the explicitly allocated globals and a small stack.
The problem is that the code section (.text) now grew beyond the 1st bank boundary and I get the following linker error message:
./bin/ld: section .data_bank1 loaded at [0000000000002000,0000000000003fff] overlaps section .text loaded at [0000000000000630,00000000000020df]
./bin/ld: section .fini loaded at [00000000000020e0,00000000000020f9] overlaps section .data_bank1 loaded at [0000000000002000,0000000000003fff]
Is there a way to see the object allocations (possibly in a temporary object file) before the linker checks for section and object overlap, and aborts the build?
You can pass the --print-map
flag to the linker. This will make it emit details of where each section from each object file is mapped into memory.
Example:
.text 0x0000000000400370 0x2c /<snip>/lib64/crt1.o
0x0000000000400370 _start
.text 0x000000000040039c 0x17 /<snip>/lib64/crti.o
*fill* 0x00000000004003b3 0xd 90909090
.text 0x00000000004003c0 0x92 /<snip>/4.6.3/crtbegin.o
*fill* 0x0000000000400452 0x2 90909090
.text 0x0000000000400454 0x21 /tmp/ccwAfGkH.o
0x000000000040045f x
0x000000000040046a y
0x0000000000400454 main
这篇关于如何列出链接器分配的代码对象w / gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!