c - KPIT GCC Allocation of text strings to specific linker sections -


i trying use kpit gcc renesas m16 cpu. compiler restricts pointers 16 bits , strings copied rom ram @ start up. fills ram. chip has data rom available in first 64k , addressable small pointers if can compiler place strings there. can't find compiler switches control placement of strings tried following:

static const char fmt[] __attribute__ ((section ("nrodata"))); static const char fmt[]="hello world"; 

which seems work if placed outside function in file. however, within function same code gives error: "storage size of 'fmt' isn't known" first line. reason want work in functions i'm considering changing printf() calls macro like:

#define printf(fmt,args...) { \       static const char _fmt_[] __attribute__ ((section ("nrodata"))); \       static const char _fmt_[]=#fmt; \       printf(_fmt_ , ##args); \     } while (0) 

to strings right section.

does know how can strings particular section?

based on gcc documentation should able specify attribute in same line variable definition, such as:

static const char __attribute__ ((section ("nrodata"))) fmt[]="hello world"; 

it may global variables, looks may allowed static variables example code. (i don't have compiler can't try it)


Comments