[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] proposal to put PROGMEM in separate sections

From: Sean D'Epagnier
Subject: [avr-gcc-list] proposal to put PROGMEM in separate sections
Date: Fri, 8 May 2009 11:46:46 -0600


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

#undef PROGMEM
//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:

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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]