Nathan Froyd <froy...@codesourcery.com> wrote on 2010/12/01 18:33:23: > > 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.
ppc32(e300c2), gcc 4.4.5 > > 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? I don't, I just noticed that -G 0 changed this into .rodata > > 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. I am just surprised that gcc doesn't place RO data into a RO section by default. As is now there is no protection against actually modifying small const data. Jocke