链接描述文件错误:部分重叠

时间:2018-07-21 15:31:29

标签: c gcc linker linker-errors linker-scripts

我正在使用链接器脚本为CASIO 9860GII计算器编写C代码(请参见最后)。不幸的是,我得到以下错误:

$ sh3eb-elf-gcc -o build/crypt.elf build/crt0.o build/crypt.o build/supercoollibrary.o -m3 -mb -ffreestanding -nostdlib -I include -O3 -std=c99 -lc -lgcc -L lib -lfx -T src/crypt.ld -nostdlib
sh3eb-elf/bin/ld: section .data._impl_stderr LMA [000000000030c308,000000000030c317] overlaps section .rodata._printf_ptr.str1.4 LMA [000000000030c308,000000000030c31b]
sh3eb-elf/bin/ld: section .rodata.CSWTCH.44 LMA [000000000030c31c,000000000030c39f] overlaps section .data._impl_stdout LMA [000000000030c318,000000000030c327]
sh3eb-elf/bin/ld: section C LMA [000000000030c328,000000000030c557] overlaps section .rodata.CSWTCH.44 LMA [000000000030c31c,000000000030c39f]
sh3eb-elf/bin/ld: section .rodata.perror.str1.4 LMA [000000000030c3a0,000000000030c3bf] overlaps section C LMA [000000000030c328,000000000030c557]
sh3eb-elf/bin/ld: warning: section `.bss' type changed to PROGBITS

现在我发现我在ROM中有两个平行的部分:

+-------------------------+----------------------------+
| 0x0030c308              | 0x0030c308                 |
|       .data_impl_stderr | .rodata._printf_ptr.str1.4 |
| 0x0030c317              |                            |
+-------------------------+ 0x0030c31b                 |
| 0x0030c318              +----------------------------+
|       .data_impl_stdout | 0x0030c31c                 |
| 0x0030c327              |                            |
+-------------------------+                            |
| 0x0030c328              |          .rodata.CSWTCH.44 |
|                         |                            |
|                         |                            |
|                         | 0x0030c39f                 |
|                         +----------------------------+
|                         | 0x0030c3a0                 |
|                       C |      .rodata.perror.str1.4 |
|                         | 0x0030c3bf                 |
|                         +----------------------------|
|                         |
|                         |
|                         |
| 0x0030c557              | 
+-------------------------+

表面上,AT(_romdata)使链接器加载.data进入.rodata节(ROM),尽管由于区域指令{{1}我希望它位于RAM中} > ram

我用很小的示例代码尝试了此链接描述文件,并且它起作用了。使用.data检查.elf文件后,我发现没有readelf部分。如果我使用“真实”代码,则会出现上述错误。当我在Windows(使用其他编译器)上编译此代码时,它工作正常。

有人可以给我一个提示吗?老实说,我很笨。

链接描述文件:

.data

1 个答案:

答案 0 :(得分:1)

似乎您的链接器脚本中有一些输入节没有映射到任何输出节。尝试在*(.rodata.*)部分说明中添加.rodata