exporting argc/argv to applets
Rich Felker
dalias at aerifal.cx
Thu Jul 6 12:18:32 PDT 2006
On Thu, Jul 06, 2006 at 11:59:37AM -0400, Rob Landley wrote:
> 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).
Global variables are not bp+offset, just fixed address. The difference
in size to access them is that sp+offset requires only one byte for
the offset when it fits in a (signed) byte, but global variables will
always have their addresses coded as 4 bytes.
> 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.
Never observed this.. can you elaborate?
> I'd have thought the savings from yanking the arguments from all the main()
> functions would have overcome that, though...
Yes I'm a bit surprised too...
Rich
More information about the busybox
mailing list