[BusyBox] uname patch and questions

David Schleef ds at schleef.org
Thu Nov 29 02:31:13 UTC 2001


On Wed, Nov 28, 2001 at 08:38:53AM -0700, Manuel Novoa III wrote:
> 
> Well... even though ack1 qualifies array as const, it is declared
> with dynamic duration.  I don't know what the fine print in the
> standard would say, but it doesn't surprise me that some compilers
> would blindly allocate and initialize (via a hidden memcpy in your
> case) array on each function call in spite of array's const nature
> and the apparent oportunity for optimization.

I would imagine that this is not the most transparent thing to
optimize away.  Or at least, something that gives compiler writers
headaches.

> I'm curious about your distrust of the compiler here.  Are you aware
> of any problems regarding static declarations at block vs. file scope?

I've seen weird things in the past, although not directly related.
They're not techinically bugs, since (as in this case) the compiler
is strictly doing the right thing, but it is easy to imagine how
it could be coded much better.  Since I'm not a compiler hacker,
I'm not going to even come close to suggesting that fixing gcc to
make this optimization is easy.  I trust gcc not to do things that
are wrong -- but not to do the thing that is least surprising.

My currently favorite weirdism is the seemingly random placement of
string literals and other data into the .data and .rodata sections.
It varies by architecture, which is not a good sign.  Again, the
compiler is not _wrong_, but (more in uClibc's case) it would be
nice to get constant data into .rodata, so it can be shared.  If I
remember correctly, the size of the .data section on PowerPC and
i386 were different by 4 or 5 pages.  With 25 processes on a system,
this could add up to .5 MB of wasted memory.  I've been meaning to
get some time to look into massaging gcc into doing the right thing,
but it's pretty low priority, because it's not _wrong_.

(By the way: a way-cool project would be to figure out a way to
have a popularity contest for variables in .data, and then load
all the most popular variables into a single page.  Extra points
for making it work on any library.)



dave...






More information about the busybox mailing list