简体   繁体   English

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

[英]Linker script error: section overlap

I'm writing C code for the CASIO 9860GII calculator using the linker script (see at the end). 我正在使用链接描述文件为CASIO 9860GII计算器编写C代码(请参见最后)。 Unfortunately I get following error: 不幸的是,我得到以下错误:

$ 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

Now i figured out that I have two sections parallel in ROM: 现在我发现我在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              | 
+-------------------------+

Seemingly, AT(_romdata) makes the linker load .data into the .rodata section (ROM), even though I would expect it to be in RAM because of the region instruction > ram for .data . 看起来, AT(_romdata)使链接器将.data加载到.rodata节(ROM)中,尽管由于区域数据> ram对于.data ,我希望它位于RAM中。

I tried this linker script with very small sample code and it worked. 我使用很小的示例代码尝试了此链接描述文件,并且该脚本有效。 After I inspected the .elf file using readelf , I noticed that there is no .data section. 使用readelf检查.elf文件readelf ,我注意到没有.data节。 If I use my "real" code, the mentioned error appears. 如果我使用“真实”代码,则会出现上述错误。 When I compile this code on Windows (using a different compiler), it works just fine. 当我在Windows上(使用其他编译器)编译此代码时,它工作正常。

Could anyone please give me a hint what is going on? 有人可以给我一个提示吗? I'm pretty clueless, to be honest. 老实说,我很笨。

Linker script: 链接描述文件:

OUTPUT_ARCH(sh3)
ENTRY(initialize)
MEMORY
{
        rom  : o = 0x00300200, l = 512k
        ram  : o = 0x08100000, l = 64k  /* 64k pretty safe guess */


        /*
        rom start  0x00300200  (+512k = +0x0007D000)
            end    0x0037D200

        ram start  0x08100000  ( +64k = +0x0000FA00)
            end    0x0810FA00
        */
}
SECTIONS
{
        .text : {
                *(.pretext)     /* init stuff */
                *(.text)
        } > rom
        .rodata : {
                *(.rodata)
                *(.rodata.str1.4)
                _romdata = . ;  /* symbol for initialization data */
        } > rom
        .bss : {
                _bbss = . ;
                _bssdatasize = . ;
                LONG(0);        /* bssdatasize */
                *(.bss) *(COMMON);
                _ebss = . ;
        } > ram

        .data BLOCK(4) : AT(_romdata) {
                _bdata = . ;
                *(.data);
                _edata = . ;
        } > ram
}

It seems that you have some input sections that you didn't map to any output section in your linker script. 似乎您有一些输入节没有映射到链接描述文件中的任何输出节。 Try adding *(.rodata.*) in your .rodata section description. 尝试在.rodata部分说明中添加*(.rodata.*)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM