🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #6203

Re: Canonical Hello!

#6203
From: Ed Falk
Date: Sun, 30 Dec 1990 01:04
42 lines
2061 bytes
In article <903@brchh104.bnr.ca> amdcad!netcom!lange@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.
Technical Details
Message-ID: <934@brchh104.bnr.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request
From: falk@peregrine.eng.sun.com (Ed Falk)
Newsgroups: comp.sys.sun
Subject: Re: Canonical Hello!
Keywords: SunOS
Message-ID: <934@brchh104.bnr.ca>
Date: 30 Dec 90 01:04:00 GMT
Sender: news@brchh104.bnr.ca
Organization: Sun-Spots
Lines: 42
Approved: Sun-Spots@rice.edu
X-Original-Date: 22 Dec 90 00:49:31 GMT
X-Refs:  Original: v9n410
X-Sun-Spots-Digest: Volume 9, Issue 410, message 6
X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu