This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ppc: const data not in RO section
- From: Joakim Tjernlund <joakim dot tjernlund at transmode dot se>
- To: Nathan Froyd <froydnj at codesourcery dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 1 Dec 2010 20:34:51 +0100
- Subject: Re: ppc: const data not in RO section
- References: <OFA0881115.65470E44-ONC12577EB.00672F4B-C12577EB.0068BF33@transmode.se> <20101201173323.GL24280@codesourcery.com>
Nathan Froyd <froydnj@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.
>
> 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.
This I find a bit strange:
gcc tst.c -Os -fpic -msdata=sysv
tst.c:1: error: -fpic and -msdata=sysv are incompatible
Yet it seems like -msdata=sysv is default as gcc generates
.sdata for variables.
Perhaps -fpic/-fPIC should imply -mno-sdata?
Jocke