> This question would be more appropriate for the mailing list > gcc-h...@gcc.gnu.org than for g...@gcc.gnu.org. Please take any > followups to gcc-help. Thanks. > > Virtual tables will normally be placed in the .rodata section which > holds read-only data. All you should need to do it arrange for the > .rodata section to be placed in FLASH rather than SRAM. This would > normally be done in your linker script.
No, it won't work. The AVR is a Harvard architecture and the FLASH is not mapped into the data address space. You need to use special instructions to fetch FLASH data into registers. You load the FLASH address in a register pair, possibly set a peripheral register to select which 64K block of the FLASH you want to address, since the register pair is only 16 bit wide and there can be up to 128K FLASH, then do a byte or word load into a register or register pair. The compiler *must* be aware of where the data is, because it needs to generate completely different code to access data in the FLASH. I haven't used the AVR for a while, but as far as I know, gcc does not provide any support for constants to be stored in FLASH, let it be const data, gcc generated tables or anything. It was a pain in the neck, because there's precious little amount of RAM on these processors, and all your strings and gcc generated internal data were wasting RAM (without you having any control over that) and even placing your own data into FLASH required a fairly convoluted use of the section attribute and inline asm routines to access it. So it is indeed a valid compiler issue, not an incompetent user issue. Probably an improvement request would be the best. Zoltan