This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bss section not getting zero-initialised vars
Mark Mitchell wrote:
>
> >>>>> "Jamie" == Jamie Lokier <jamie.lokier@cern.ch> writes:
>
> Jamie> Richard Henderson wrote:
> >> > Yes, this is true. gcc doesn't have the optimization where
> >> we move > zero inited things into bss.
> >>
> >> Yes, and there's a good reason historical for this. Providing
> >> an initialization is a (reasonably portable) way to force the
> >> variable into the data section, where it can then be edited in
> >> the binary.
>
> I think this is one of those places where the embedded folks and the
> non-embedded folks don't see eye to eye.
I think a lot of embedded folks would like to have such an optimisation,
in order to shrink their ROM/Flash images.
I guess gcc would provide something like -fno-initialised-variables-in-bss
or what have you.
Some embedded folks even try to write portable, compliant code...
On the other hand, I once had to program a family of embedded 68k boxes
which had battery backed RAM. Bss was *not* zeroed on leaving
reset: variables which needed to be non-volatile were not explicitly
initialised, so they went into the battery-backed bss. Names witheld
to protect the guilty.
I hope that any feelings of nausea or giddyness this message may have
caused will pass quickly.
Regards,
John.