I have run into this consistently over the last weeks and I finally cannot avoid it. I am using an ATmega1280 with C code, the AVR library, and FreeRTOS. As my compiled code comes close to the 65536 byte boundary, the GNU linker seems to go nuts -- it starts overlaying parts of the AVRlib code into other parts of code.
I have not found a simple example of this, unfortunately. Just setting up sections in high memory doesn't trigger the problem. I really am not interested in posting 25 K lines of code to the forum. I would be happy to post tidbits from the map and .lss files, if those would be useful.
I am using -Os optimization (-O0 ran into the problem much earlier). I cannot use -mcall-prologues as I have the BootLoader in High Flash and that option confuses the BootLoader. Anyway, the optimization really doesn't seem to be the problem, it seems to be the linker.
Any ideas? I'm happy to post more info as needed. As a fallback position, I'm investigating both CodeVisionAVR and IAR compilers, but that appears to be some work to move the code.
Thanks for any help!