[Top][All Lists]

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

[avr-chat] linker builds file too big, is it a bug?

From: Massimiliano Cialdi
Subject: [avr-chat] linker builds file too big, is it a bug?
Date: Fri, 11 Feb 2011 13:25:39 +0100


Working on a project I have found a strange pitfall with avr-ld.

To reproduce I wrote a very simple project.
Consider that I use avr-gcc 4.4.4 and binutils 2.20.1

I have a c file:

#include <stdint.h>

static uint8_t data[] =
        [0 ... 9] = 1,
        [10 ... 99] = 2,
        [100 ... 999] = 3,
        [1000 ... 1499] = 4

int main (void)
                __asm__ __volatile__ ("nop"); // do nothing
        return (0);

Suppose to have an avr micro with only 1K flash and 2K sram. the MEMORY
command will be:

  text   (rx)   : ORIGIN = 0, LENGTH = 1K
  data   (rw!x) : ORIGIN = 0x800060, LENGTH = 2K
  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 1K

If I compile and link I would expect a linker error like:
region `text' overflowed by xx bytes

none of this happens. avr-ld link the elf file without error.
bin file extracted from elf is 1662, too big to fit the flash...

.text is about 160 bytes, and .data is 1500 bytes.
here is the output of avr-size:

Program:    1662 bytes (5.1% Full)
(.text + .data + .bootloader)

Data:       1500 bytes (73.2% Full)
(.data + .bss + .noinit)

I know that .data is to be considered belonging to sram, but its initial
image is hold in flash, and according to my opinion this fact must be
take into account, otherwise the binary may not work (as happened to my
real project)

the sample project is here:

is this a bug?

best regards

reply via email to

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