i discovered a bug with mega2560 and ide 1.0.3 (ubuntu 12.10)
compiling a program with a size of ~33kb and adding Serial.x stuff makes the linker throw the following error:
/home/--/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/lib/avr6/crtm2560.o: In function `__bad_interrupt':
../../../../crt1/gcrt1.S:193: relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_46' defined in .text section in /home/--/arduino-1.0/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/lib/avr6/crtm2560.o
removing the --relax linker option fixes that (beginning at line 193 in Compiler.java).
furthermore i dont know why exactly relaxation is enabled on mega2560?
from the avr-gcc description:
Enables linker relaxations. By default, the linker links functions will a full CALL statement,
which is wasteful if two functions are near each other.
Relaxations will do more in the future, but currently (AFAIK) just replace CALL
statements with RCALL where possible to save a few bytes.
but afaik rcall can only jump to regions +-4kib away! the mega2560 has 256kib flash,
im in doubt about the compiler can optimize every call to rcall to within +-4kib limit.
am i overlooking something?
side hint: hard coding such exception seems not the right solution to me (i searched and grepped a long bit).