exporting argc/argv to applets

Rob Landley rob at landley.net
Thu Jul 6 15:59:37 UTC 2006


On Sunday 02 July 2006 9:36 am, Bernhard Fischer wrote:
> Hi,
>
> FYI, I've been pondering ¹) landley's suggestion to export argc
> and argv globally, so we wouldn't have to pass it around as arguments.
>
> From a cursory look, this doesn't seem to be a good idea, though:

I didn't say it was a good idea, just an idea. :)

>    text	   data	    bss	    dec	    hex	filename
>  862418	  10156	 644740	1517314	 172702	busybox.old
>  865586	  10156	 644708	1520450	 173342	busybox
>
> Could very well be that i did something wrong/incomplete, admittedly.

On x86 especially, registers are a scarce resource.  It turns out to be 
smaller to deal with all stack variables (sp+offset) or all global variables 
(bp+offset).  Switching back and forth between the two seems to result in 
bigger code.  I dunno if it confuses the optimizer or if it's just a hard 
problem in a register starved environment like x86.

This is the kind of micro-optimization that I try not to care too much about 
because it'll just drive you _crazy_ trying to think like that.  But it could 
be what you're hitting.

I'd have thought the savings from yanking the arguments from all the main() 
functions would have overcome that, though...

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list