Canonical Hello!
Ed Falk
falk at peregrine.eng.sun.com
Sun Dec 30 12:04:00 AEST 1990
In article <903 at brchh104.bnr.ca> amdcad!netcom!lange at ames.arc.nasa.gov (Christopher Lange) writes:
>
>main() {
> printf("Hello, world!\n") ;
> system("ksh $a/c/hello.explained") ;
> exit(0);
>}
[produces a 24k executable]
>which, I would say, means that Sun loses... .
[our moderator tries this on different systems:
> Apollo (Domain/OS SR10.1) 2715 bytes
> HP-9000 (HPUX 6.5) 5114 bytes
> Sun (4.0.3 & 4.1) 24576 bytes
>
>So that was kind of interesting, so I looked at object code output (cc -c)
>
> Apollo 1391 bytes
> HP-9000 103 bytes
> Sun 80 bytes (Sparcstation, 4.1)
> Sun 78 bytes (Sun 3/60, 4.0.3)
>
>So, most of the space is taken up in the link/load process. Note that by
>stripping the relocation bits (ld -s), you can reduce the size of the
>executable to 16384 bytes. -bdg]]
You can do a *lot* better than that, if you want. The reason the Sun
executable is so large seems to be the fact that things are being aligned
on page boundaries so that the text can be shared. If you don't care
about sharing the text, compile like this:
% cc -O -n -Bdynamic -o hello hello.c
% strip hello
% ls -l hello*
-rwxrwxr-x 1 falk 1344 Dec 21 16:44 hello*
-rw-rw-r-- 1 falk 89 Dec 21 16:44 hello.c
Disclaimer: I'm not a compiler guru, just an end user. I'm sure some
compiler guru could tell me I'm all wet.
More information about the Comp.sys.sun
mailing list