Message-ID: Tests and Expected Results -------------------------- Trampolines, etc., must be in lower 128 KiB: Just fits in: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP0=0x1f000 -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Idx Name Size VMA LMA File off Algn 0 .data 00000000 00800200 0003f16e 0003f1e2 2**0 CONTENTS, ALLOC, LOAD, DATA 1 .lowtext 0001f10c 00000000 00000000 00000074 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .hightext 00020062 0001f10c 0001f10c 0001f180 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE .data LMA butts up to .hightext, which butts up to .lowtext. Overflows: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP0=0x20000 -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Error: .lowtext (128KiB limit) overflow. Try shrinking .progmem? Locate __flashN at 0xN0000: Just fits in: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP1=0x10000 -DP3=0x87ff -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Idx Name Size VMA LMA File off Algn 0 .data 00000000 00800200 00058862 00038a22 2**0 CONTENTS, ALLOC, LOAD, DATA 1 .lowtext 0000010c 00000000 00000000 000000b4 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .flash1 00010000 00010000 00010000 000001c0 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .flash3 000087ff 00030000 00030000 000101c0 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .hightext 00020063 000387ff 000387ff 000189bf 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE Note: .hightext (where input section .text goes) butts up to 000387ff, using all spare .flash3. (From the next even byte address, inside .hightext.) .data in flash does the same with .hightext, at 00058862. Overflows: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP1=0x10001 -DP3=0x10001 -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Error: __flash1 (64KiB limit) overflow. Need to shrink it Error: __flash3 (64KiB limit) overflow. Need to shrink it. Overlaps prior section: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP0=0x10000 -DP1=0x87ff -DTEXT=0x20000 -mmcu=atmega2560 flash.sx section .flash1 loaded at [00010000,000187fe] overlaps section .lowtext loaded at [00000000,0001010b] flash.elf: section .flash1 vma 0x10000 overlaps previous sections but ld also says this, which isn't helpful: section .hightext vma 0x187ff overlaps previous sections Overlaps following section: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DP1=0x10001 -DP2=0x87ff -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Error: __flash1 (64KiB limit) overflow. Need to shrink it. section .flash2 loaded at [00020000,000287fe] overlaps section .flash1 loaded at [00010000,00020000] flash.elf: section .flash2 vma 0x20000 overlaps previous sections and again: flash.elf: section .hightext vma 0x287ff overlaps previous sections The bulk of code (.text -> .hightext) snugs down if there are no __flashN: $ avr-gcc -T avr6.x-new -Wl,-Map,flash.map -o flash.elf -DSTUBS=10 \ -DTEXT=0x20000 -mmcu=atmega2560 flash.sx Idx Name Size VMA LMA File off Algn 0 .data 00000000 00800200 0002016e 000201e2 2**0 CONTENTS, ALLOC, LOAD, DATA 1 .lowtext 0000010c 00000000 00000000 00000074 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .hightext 00020062 0000010c 0000010c 00000180 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE .hightext now follows imediately from .lowtext.