This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about output section LMA


Hi miloody,

when I link the script as I attached, the linker will complain that
.data section overlaps .rodata.str1.4 and .rodata.cst8 as below:

You do not say which version of the linker you are using, so I will assume that it is the latest.


mips2_fp_le-ld: section .data [00000000800090c0 -> 00000000800093d7]
overlaps section .rodata.str1.4 [00000000800090c0 -> 0000000080009143]

This happens because you have not specified where any of the .rodata.* sections should be placed in your link.xn linker script. The linker chooses to place the .rodata.str1.4 section at the end of the .text section (since both of these sections are read-only), but your script also places the .data section immediately after the end of the .text section.


but if I mark LMA part in .data section as below:
  .data :
/*  AT( _etext_init ) */

By commenting out the AT statement you are allowing the .data section to be moved so that the linker can place it after the end of the .rodata.* sections, and hence eliminating the overlaps.



but why linker will tell me sections are overlapped when I use LMA?

Because the linker is telling you that at *load* time, the .data section and the .rodata.str1.4 sections are both being loaded into the same memory region. This is not where those sections may be once *exection* starts, since that is controlled by the VMA address. But the LMA address specifies where sections are loaded into memory, before they are moved to their VMA addresses. So if two sections are going to be loaded into the same region of memory there is going to be a clash.


Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]