Char *Foo = "ABC" or Char Foo[] = "ABC"" ?
Richard Henderson
rth@redhat.com
Fri Oct 7 19:06:00 GMT 2005
On Fri, Oct 07, 2005 at 07:06:21PM +0100, Felix Oxley wrote:
> > For variables marked __initdata, the "*foo" form causes only the
> > pointer, not the string itself, to be dropped from the kernel image,
> > which is a bug.
Not a bug. A missing feature, perhaps, but not a bug.
> > http://lists.osdl.org/pipermail/kernel-janitors/2005-May/004146.html
He did something wrong. The size numbers he gives are obviously
wrong -- the data field is 0 in cases that cannot be true. I don't
replicate his results either. E.g.
text data bss dec hex filename
11 8 0 19 13 s1.o
0 11 0 11 b s2.o
That said, some ABIs over-align arrays, and so you might get more
padding with arrays than raw strings. But it'll be less than the
size of an extra pointer variable.
> The second part of the task was descibed thus:
> > 2) "unsigned int" is preferred to "int", it generates better asm code on
> > all platforms except sh5. This replacement needs to be done manually,
> > because often 'int' is required due to negative values -Exxx commonly
> > passed as error values.
>
> Can anyone comment on the accuracy of this?
Definitely false for mips and alpha, so I really doubt the accuracy
of their survey of all platforms. My guess is that it allows for the
possibility of better code for x86_64 (but is not totally realized;
there's a large outstanding gcc patch that attempts to fix this), but
is mostly a wash elsewhere.
r~
More information about the Gcc
mailing list