Dang-nabit, there's a bug in the patch in the previous post. Maybe I should
have packed up earlier in the evening, before last minute changes.

Talking about testing, we also error explicitly if the user overflows
all of flash by grossly overflowing a flashN, other than the last:

$ avr-gcc -T avr6.x-test -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \
  -DP0=0x87ff -DP2=0x20000 -mmcu=atmega2560 flash.sx

../../../avr/bin/ld: Error: text overflows available flash memory.
../../../avr/bin/ld: Error: __flash2 (64KiB limit) overflow. Need to shrink it.
../../../avr/bin/ld: Error: text overflows available flash memory.
../../../avr/bin/ld: Error: __flash2 (64KiB limit) overflow. Need to shrink it.
../../../avr/bin/ld: Error: text overflows available flash memory.
../../../avr/bin/ld: Error: __flash2 (64KiB limit) overflow. Need to shrink it.

My prior reply to this:

> 2. If the linker scripts are made generic (Adding in scripttempl/avr.sc),
> can we control the number of flashN sections in the linker scripts as
> per the size of flash in the device ?

was too busy with why the existing script does not need customised
flashN counts, to concisely answer the question directly. We can do it.
If we move the .flashN output sections from the script template to being
generated by individual avr6X.sh files, then the number of pages will be
customised according to device. That still doesn't seem very useful to
me, though, since the excess empty .flashN sections harmlessly vanish if
not populated. Is there another reason for doing it, or do your
avr-objdump results not show that unpopulated .flashN sections vanish?
(With zero memory cost.)

Erik

-- 
What is this talk about releases? We do not make software "releases".         
Our software escapes, leaving a bloody trail of designers                     
and quality assurance people in its wake!                   - Klingons

--- avr6.x-new  2013-03-18 19:26:11.000000000 +1100
+++ avr6.x-test 2013-03-18 20:01:48.000000000 +1100
@@ -1,6 +1,7 @@
 /* Default linker script, for normal executables */
 OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
 OUTPUT_ARCH(avr:6)
+__total_text = 256K ;
 MEMORY
 {
   text   (rx)   : ORIGIN = 0, LENGTH = 1024K
@@ -124,6 +125,8 @@ SECTIONS
 
   .hightext :
   {
+    x = ASSERT (. <= __total_text, "Error: FlashN page placed beyond available 
flash memory.") ;
+
     /* The following is OK to follow preceding sections
        at any even byte address, on any page. */
 
@@ -190,6 +193,9 @@ SECTIONS
      _edata = . ;
      PROVIDE (__data_end = .) ;
   }  > data
+
+    x = ASSERT (_etext + SIZEOF(.data) <= __total_text, "Error: text + data 
overflows available flash memory.") ;
+
   .bss   : AT (ADDR (.bss))
   {
      PROVIDE (__bss_start = .) ;
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to