avr-chat
[Top][All Lists]
Advanced

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

A convenient work-around Re: [avr-chat] linker builds file too big, is i


From: Erik Christiansen
Subject: A convenient work-around Re: [avr-chat] linker builds file too big, is it a bug?
Date: Fri, 18 Feb 2011 01:31:01 +1100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Fri, Feb 11, 2011 at 04:56:08PM +0100, Massimiliano Cialdi wrote:
> No, Is not right.
> You haven't specified linker script.
> 
> Just run make in the same directory.
> 
> here is the results:
> 
> lab7:/home/max/prog/test_avr-ld$ make
> avr-gcc -g -Wall -O0 -Wa,-anhlmsd=test.lst -mmcu=atmega32 -c test.c
> test.c:4: warning: 'data' defined but not used
> avr-gcc -g -O0 -Wall -mmcu=atmega32 -Wl,-Tavr5_mega32.x
> -Wl,-Map=test.map -o test.elf test.o
> avr-objcopy -O binary -R .eeprom -R .fuse -R .lock test.elf test.bin

Massimiliano, this is the only effective work-around I've found so far,
but I like it. It uses legit ld linker script syntax to do our own
checking, and works for me, with binutils version 2.18.0:

  . = ASSERT (_etext + SIZEOF (.data) <= 32K , "Error: .text + .data
  collectively overflow the text region." ) ;
                                                      [1]
which generates:

avr-gcc -g -Wall -O0 -Wa,-anhlmsd=test.lst -mmcu=atmega32 -c test.c
test.c:4: warning: ‘data’ defined but not used
avr-gcc -g -O0 -Wall -mmcu=atmega32 -Wl,-Tavr5_mega32.x
-Wl,-Map=test.map -o test.elf test.o
/usr/lib/gcc/avr/4.2.2/../../../../avr/bin/ld: Error: .text + .data
collectively overflow the text region.
/usr/lib/gcc/avr/4.2.2/../../../../avr/bin/ld: Error: .text + .data
collectively overflow the text region.
/usr/lib/gcc/avr/4.2.2/../../../../avr/bin/ld: Error: .text + .data
collectively overflow the text region.
make: *** [test.elf] Error 1

OK, it's not perfect having "32K" both at MEMORY and here, but the
former won't allow variables, so a full single-point-definition isn't so
easy. We could work on that, perhaps. Still, this detects cumulative
text region overflow for you.

I've attached the modified version of your linker script which I used to
test this (on your example). Hopefully it'll "just work" for you too.

Erik

[1] _etext is the same as ADDR (.text) + SIZEOF (.text)
    and you could use the latter instead, if preferred.

-- 
If at first you don't succeed, try again.
Then Quit. No use being a damn fool about it.              - W.C. Fields

Attachment: avr5_mega32.x
Description: Text document


reply via email to

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