On Tue, Nov 30, 2010 at 08:04:06PM +0100, Joakim Tjernlund wrote: > Why is not > const char cstr[] = "mystr"; > const int myint = 3; > added to a read only section? > Especially since > const int myarr[]={1,2,3}; > is placed in .rodata. > > hmm, -G 0 does place these in .rodata but why do I have to specify that?
It would help if you specified the target and the compiler version that you used. The compiler I have (~4.5) places myint and mystr in .sdata; since they're so small, GCC thinks that placing myint and mystr in .sdata is beneficial. Why do you think -G 0 should be the default? It does seem kind of odd that "mystr" is placed in .sdata, since rs6000_elf_in_small_data_p indicates that string constants shouldn't be in .sdata. You could investigate and submit a patch or file a bug. -Nathan