Re: Unnecessary zero initializers bloating .data

Peter Samuelson (peter@wire.cadcamlab.org)
19 Dec 1999 16:27:31 -0600


[Bradley D. LaRonde <brad@ltc.com>]
> I think there are some unnecessary (and not benign) initializers here
> and there in the kernel.
[...]
> Why explicitly initialize those arrays with 0?

Documentation. ISO rules aside, explicitly initializing what you will
be relying on to be initialized is a good way to make your code more
readable. It says "I may not intend to initialize this at runtime."

> I see no reason to use those zero initializers. The kernel appears
> to initialize .bss to zero in head.S. for almost every architecture
> (i386, arm, mips, ppc, sh, sparc - don't know what is up with alpha),
> so it seems safe to assume that uninitialized data is 0.

My opinion on that matter is that gas should be taught about the
we-plan-to-zero-bss-anyway optimization. (As an option flag, perhaps.)
That way we can keep the initializers and gas will ignore whichever
ones happen to be zeroes.

> This simple patch alone cuts the on-disk size of the kernel by over 8k, and
> it looks like it is just the beginning of removing bloat from .data:

I haven't tried your patch, but considering what gzip does to long
strings of nulls, I have to ask: are you talking about vmlinux or
zImage?

Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/