Hello,

I have recently had much success by the PROGMEM definition suggested
by curtvm on the avrfreaks forum.  At the end of pgmspace.h I
inserted:

//undefine
#undef PROGMEM
//redefine
#define PROGMEM MAKE_PGM_SECTION_(__LINE__)
//expand __LINE__
#define MAKE_PGM_SECTION_(line) MAKE_PGM_SECTION__(line)
//join .progmem.line
#define MAKE_PGM_SECTION__(line) MAKE_PGM_SECTION___(.progmem.##line)
//stringify to section attribute
#define MAKE_PGM_SECTION___(name) __attribute__((section(#name)))

The forum topic:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=78644

What this does is put each PROGMEM definition in a separate section so
that the linker option --gc-sections can remove unused data sections
in flash (before it would only work for code, and ram data but not
flash data)

I would use #ifdefs to check if the gcc supports __COUNTER__ instead
of line (so multiple progmem definitions can be on the same line
without section conflict)

I propose adding this to avr-libc.. it seems like only a benefit since
it can reduce code size (in my case by 4kb) any objections?

Sean


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to