Skip to contentSkip to conversation

An "ELKS BusyBox" is in progress; 24.5% size savings so far!

DISCUSSION Jody Bruchon 2 participants 3 messages Feb 20, 2012 – Feb 28, 2012 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

I'm pleased to announce my development of a sub-project I am coining "BusyELKS" which serves the same purpose for ELKS that BusyBox does for larger Linux systems. I have spent most of my evening combining the files under elkscmd/sh_utils into a unified binary that executes the requested command based on its invocation name, and the savings just for sh_utils is awesome! Ignoring the "uname" tool which currently does not compile, the binary size total drops from 61920 to 46732, a whopping 15188-byte (24.5%) drop in size! See for yourself:

648     ../sh_utils/basename
7232    ../sh_utils/date
536     ../sh_utils/dirname
360     ../sh_utils/echo
212     ../sh_utils/false
536     ../sh_utils/printenv
1836    ../sh_utils/pwd
212     ../sh_utils/true
3788    ../sh_utils/which
1896    ../sh_utils/whoami
328     ../sh_utils/yes
1896    ../sh_utils/logname
7256    ../sh_utils/tr
8320    ../sh_utils/xargs
7900    ../sh_utils/mesg
16148   ../sh_utils/stty
2816    ../sh_utils/test

-----
61920 total

-rwxr-xr-x 1 root root 46732 Feb 20 00:40 busyelks*

My preliminary binary isn't ready to be put to use yet; I still have that pesky 64K barrier that I will have to fight with eventually, and there are many more optimizations I haven't performed, but it's a start! Even if I can only unify the utilities by category, we can look forward to significant space savings from this effort. Once I've got the structure cleaned up a bit and some disparities merged together, I'll commit BusyELKS to Git. Stay tuned.

Jody Bruchon

A message that is not in the archive (sent off-list or not yet received): CAMKR1ysa2wnb=kPK3DMpqfT3i87exO5SKZDrTs-VpGOv1Ugy_Q@mail.gmail.com

#2 lore raw
Quoted 4 lines · Kirn Gill

Most of the space-savings comes from not having to duplicate the C library around (due to static linking). If there was a shared library mechanism (which someone once suggested via interrupt vectors - does that even work?), then this space-savings would be far less.

That's not entirely true. Some of the commands are from sash, and have tons of 1:1 copied code to split them into separate commands, and I have fixed that up; some other commands shared routines as well, and those are also combined. The C library is not the only duplication waste involved. Additionally, commands like "true" and "false" are so trivial that their .c files were destroyed in favor of pushing their code into a single line in busyelks.c. I have yet to merge the usage() calls together, but I've already packed a lot of stuff into one executable, and it works as expected using the elksemu command. Once I get some of the ugliness fixed up, I'll push this to Git.

13682 ./sed.o  13058 ./stty.o  11599 ./compress.o
10680 ./diff.o  8806 ./find.o  8582 ./sort.o
8423 ./ed.o   5592 ./banner.o  3647 ./tar.o

3549 ./ls.o 3105 ./cut.o 3021 ./test.o
2633 ./grep.o 2593 ./dd.o 2565 ./tail.o
2347 ./cal.o 2254 ./sash.o 2003 ./tr.o
1897 ./cksum.o 1869 ./date.o 1771 ./uniq.o 1696 ./xargs.o 1594 ./lib/wildcards.o 1594 ./du.o
1526 ./wc.o 1475 ./l.o 1419 ./busyelks.o

1299 ./write.o  985 ./cmp.o   820 ./head.o
785 ./more.o  779 ./mkdir.o   764 ./lib/copyfile.o
762 ./tee.o   738 ./rmdir.o   699 ./mknod.o

697 ./mesg.o 676 ./ln.o 580 ./cat.o
571 ./which.o 569 ./lib/sashlib.o 509 ./mv.o
477 ./chgrp.o 476 ./chown.o 437 ./lib/modestring.o
430 ./printenv.o 420 ./basename.o 358 ./mkfifo.o
343 ./chmod.o 334 ./cp.o 326 ./rm.o
314 ./dirname.o 301 ./touch.o 287 ./lib/timestring.o 269 ./lib/chunks.o 262 ./lib/buildname.o 243 ./echo.o
238 ./whoami.o 233 ./logname.o 201 ./yes.o
194 ./pwd.o 179 ./lib/stripslash.o 139 ./lib/isadir.o
134 ./usage.o 132 ./lib/basename.o

text    data    bss     dec     hex     filename
51904   7576    37124   96604   1795c   busyelks

-rwxr-xr-x 1 root root 59512 Feb 22 09:33 busyelks*

Jody Bruchon

#3 lore raw
In reply to Jody Bruchon
Quoted 25 lines · Jody Bruchon

I'm pleased to announce my development of a sub-project I am coining "BusyELKS" which serves the same purpose for ELKS that BusyBox does for larger Linux systems. I have spent most of my evening combining the files under elkscmd/sh_utils into a unified binary that executes the requested command based on its invocation name, and the savings just for sh_utils is awesome! Ignoring the "uname" tool which currently does not compile, the binary size total drops from 61920 to 46732, a whopping 15188-byte (24.5%) drop in size! See for yourself:

648     ../sh_utils/basename
7232    ../sh_utils/date
536     ../sh_utils/dirname
360     ../sh_utils/echo
212     ../sh_utils/false
536     ../sh_utils/printenv
1836    ../sh_utils/pwd
212     ../sh_utils/true
3788    ../sh_utils/which
1896    ../sh_utils/whoami
328     ../sh_utils/yes
1896    ../sh_utils/logname
7256    ../sh_utils/tr
8320    ../sh_utils/xargs
7900    ../sh_utils/mesg
16148   ../sh_utils/stty
2816    ../sh_utils/test
Quoted 1 line

-----

In the source bcc development package, under the directory "tests", there is the source of
a "ft" (file tool) command. The last version includes 15 file utilities such as cat, cp mkdir, etc.
apparently not as basic as their elkscmd counterparts. It might be worth to copy the file to elkscmd.