avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Linker(Script) Problem with WinAVR20071221


From: Suedholt, Guido
Subject: [avr-gcc-list] Linker(Script) Problem with WinAVR20071221
Date: Mon, 3 Mar 2008 10:02:45 +0100

Hi!

Joerg Wunsch gives me the hint to post the following
problem to this mailing list.
I am not sure if it is a general problem in the
linker scripts or if it is a problem of mine.

The linker script avr5.x (WinAVR20071221) for the ATmega128
contains the following area:

  .data : AT (ADDR (.text) + SIZEOF (.text))
  {
     PROVIDE (__data_start = .) ;
    *(.data)
    *(.data*)
    *(.rodata)  /* We need to include .rodata here if gcc is used */
    *(.rodata*) /* with -fdata-sections.  */
    *(.gnu.linkonce.d*)
    . = ALIGN(2);
     _edata = . ;
     PROVIDE (__data_end = .) ;
  }  > data
  .bss : SIZEOF(.data) + ADDR(.data) :
  {
     PROVIDE (__bss_start = .) ;
    *(.bss)
    *(.bss*)
    *(COMMON)
     PROVIDE (__bss_end = .) ;
  }  > data

I am not an expert for linker scripts, but for the following
example I discovered a problem:

ATmega128
               Start    End        Length
.text          0x000000-0x000fff   (0x1000)
.text_special  0x002000-0x002fff   (0x1000)
.data          0x800100-0x800fff   (0x0f00)
.bss           0x801000-0x804fff   (0x4000)

With my limited knowledge I see the following (faulty?)
behaviour:

With
  .data : AT (ADDR (.text) + SIZEOF (.text))
the initialization data for the .data section is located
after  the end of the .text section, in this example to
0x001000-0x001eff.

With
  .bss : SIZEOF(.data) + ADDR(.data) :
the .bss section is put after the end of the .data section,
resulting in a location of 0x001f00-0x005eff.

This proceeding results in an apparent overlapping with
the .text_special section and the IMHO unnecessary linker
error message "section .text_special overlaps section .bss".

By using the linker switch -Wl,--no-check-sections the 
linker error message could be suppressed and the linked
file is correct, but this is not a very clean solution,
I think.

Currently I am using WinAVR20071221 (avr-gcc 4.2.2),
in the previous release WinAVR20070525 this problem did not
occur.

Attached are two map files of a real project:
A AVR bootloader for the ATmega128, linked with the
previous and current WinAVR version. The crucial
difference seem to be the following lines, which
are IMHO responsible for the section overlap:

WinAVR20070525:
.bss            0x00800102      0x8e4

WinAVR20071221:
.bss            0x00800102      0x8e4 load address 0x0001fbe6

For what reason the load address of the .bss section
is located to the end of the .text / .data section and
therefore loaded (load address) in FLASH?

Finally (after linking) the .bss section resides at the
correct address in RAM, but at least for the
section overlap check the linker deals with this
(faulty?) load address and generates under some circumstances
(other .text sections) a section overlap error.

Has anyone an idea what is going wrong or what can be done to
avoid this problem?

If you need further information, please contact me.

Thanks for your attention & Regards.
  Guido Suedholt

Attachment: bootlfc.WinAVR20070525.map
Description: bootlfc.WinAVR20070525.map

Attachment: bootlfc.WinAVR20071221.map
Description: bootlfc.WinAVR20071221.map


reply via email to

[Prev in Thread] Current Thread [Next in Thread]