Subject: Size of static binaries
To: Boris Gjenero <bgjenero@undergrad.math.uwaterloo.ca>
From: David Brownlee <abs@anim.dreamworks.com>
List: port-vax
Date: 02/21/1998 21:41:49
	(Was: 'Re: Precompiled vax packages anyone?')

On Sat, 21 Feb 1998, Boris Gjenero wrote:

> [BSD4.3 -> 4.4]
>
> As for the change in binary sizes, that's surely just bloat.  I don't
> know what they did.  Did they get Microsoft to rewrite it for them?  
> 
	One big source of bloat (In NetBSD) is that just about everything
	has to link with the YP support, message catalogs, etc... nasty.

> Unfortunately, NetBSD continues the tradition of bloat.  /bin/cat is 33k
> (yes, stripped!).  With gzip -9 it's down to 19k, so that means it
> actually contains data and not holes and/or large blocks of zeros.  If
> you stop and think about that, it's totally ridiculous and disgusting. 
> I know most people just get more RAM and disk space and they don't
> complain about it, but I just see it as a very good reason not to
> upgrade (and a reason why your 4.3BSD project (if it ever actually)
> happens) may be interesting).

	On NetBSD/sparc (My Vax is off right now :), the cat.o is less
	than 3K. Since NetBSD/sparc uses 8k pages, and everything (useful)
	needs a text and data segment, that means the smallest executable
	has to use two pages, or 16k.

	A static version ends up at 64k, because it includes a boatload of
	function from libc (list of symbols at end).

text    data    bss     dec     hex
2904    0       8       2912    b60		cat.o
8192    8192    0       16384   4000		cat (dynamic)
57344   8192    0       65536   10000		cat (static)

    Options:

	a) Move back to BSD4.3. (Assuming your hardware is supported).
	   I think I might miss the functionality.
	a) Live with this for the files in the root filesystem, which need to
	   be static in case you need to rebuild a badly broken system.
	b) Produce 'small' versions of the programs/libraries by throwing
	   away functionality (some programs may already do this for install
	   media).
	c) Dyamically link everything. Nice performance gain, and the
	   executables are now _smaller_ than 4.3. However, if you lose your
	   shared libraries you are hosed until you can boot from some other
	   media.
	d) Use 'crunched binaries' - where you have one executable with each
	   program's code, and one copy of any library routines. All static.
	   Very useful for install media (NetBSD/i386 can boot a compressed
	   kernel from a 1.44MB, which contains an embedded root filesystem
	   with enough crumnched binaries to install a system).
	
	/usr/src/lib/libc/Makefile has default CFLAGS+=
		-DNLS		message catalog
		-DYP		NIS (Yellow Pages)
		-DLIBC_SCCS	include sccsid strings in library objects
		-DSYSLIBC_SCCS	Ditto for syscall stubs
		-D_REENTRANT	Support reentrant calls (for threads)

	I'm just going to link cat against a static libc withut those
	defined and see what is saved (for reference).

		David/absolute

		     He who laughs, lasts...

	List of symbols in default static 'cat' binary (NetBSD/sparc)

__C_ctype_ __C_tolower_ __C_toupper_
__CurrentMonetaryLocale __CurrentNumericLocale __DefaultMonetaryLocale
__DefaultNumericLocale ___CTOR_LIST__ ___DTOR_LIST__ ___atexit
___cleanup ___do_global_ctors ___do_global_dtors ___dtoa ___errno
___findenv ___flt_rounds ___fstat13 ___gnu_compiled_c ___infinity
___loadctype ___main ___mlocale_changed ___nlocale_changed ___progname
___ps_strings ___qdivrem ___sF ___savectype ___sclose ___sdidinit
___sflags ___sflush ___sfp ___sfvwrite ___sglue ___sinit ___smakebuf
___sread ___srefill ___srget ___sseek ___strerror ___swbuf ___swhatbuf
___swrite ___swsetup ___syscall ___sysctl ___udivdi3 ___umoddi3
__catclose __catgets __catopen __cleanup __ctype_ __err __exit
__exit_dummy_decl __exit_dummy_ref __fstat13.o __fwalk __main.o
__strerror.o __sys_errlist __sys_nerr __syscall.o __sysctl.o
__tolower_tab_ __toupper_tab_ __verr __vwarn __warn _atexit _bcopy
_bflag _bsize.12 _buf.13 _close _cook_args _cook_buf _copyright
_def_monetary.o _def_numeric.o _edata _eflag _end _environ _err
_err.o _errno _errno.o _etext _exit _exit.o _exit.o _exit.o.o
_f_prealloc _fclose _fflush _filename _fopen _fprintf _fread _free
_fwrite _getdtablesize _getenv _getopt _getpagesize _getrlimit
_ioctl _isatty _isinf _isnan _localeconv _lseek _main _malloc _mblen
_mbstowcs _mbtowc _memchr _memcmp _memcpy _memmove _mmap _munmap
_nflag _open _optarg _opterr _optind _optopt _optreset _raw_args
_raw_cat _rcsid _read _realloc _realloc_srchlen _rval _sbrk _setbuf
_setlocale _setvbuf _sflag _snprintf _strchr _strcmp _strerror
_strlen _strncmp _strncpy _strrchr _strtod _sysconf _sysctl _tcgetattr
_tflag _tolower _toupper _vflag _vfprintf _warn _warn.o _wcstombs
_wctomb _write atexit.o bcopy.o cat.o catclose.o catgets.o catopen.o
cerror cerror.o close.o ctype_.o ctypeio.o curbrk err.o errlist.o
exit.o fclose.o fflush.o findfp.o flags.o flt_rounds.o fopen.o
fprintf.o fread.o fvwrite.o fwalk.o fwrite.o gcc2_compiled.
getdtablesize.o getenv.o getopt.o getpagesize.o getrlimit.o infinity.o
ioctl.o isatty.o isinf.o isnan.o localeconv.o lseek.o makebuf.o
malloc.o memchr.o memcmp.o memcpy.o memmove.o mmap.o multibyte.o
munmap.o open.o qdivrem.o read.o refill.o rem.o rget.o sbrk.o sdiv.o
setbuf.o setlocale.o setvbuf.o snprintf.o start stdio.o strchr.o
strcmp.o strerror.o strlen.o strncmp.o strncpy.o strrchr.o strtod.o
sysconf.o sysctl.o tcgetattr.o tolower_.o toupper_.o udiv.o udivdi3.o
umoddi3.o umul.o urem.o verr.o vfprintf.o vwarn.o warn.o wbuf.o
write.o wsetup.o