Tip Concerning Massive COFF Comment Sections

Rick Richardson rick at pcrat.uucp
Fri Jun 1 23:44:59 AEST 1990

I recently had to reinstall the development system libraries
from INTERACTIVE 386/ix 2.0.2, and this reminded me of an
important tip for software developers that ought to be passed on.

First, some background info:

COFF files have a comment section which eliminates the need
to put char sccsid[] = "@(#) ..." in the .data of your program.
Instead, this info is just carried around in the COFF file but
never loaded into the address space.  The "#ident" cpp directive
and the "mcs" command are used to add this information to a COFF

Now, some reality:

Nearly all of the common include files, such as <stdio.h> have
#ident lines in them.  This means that any program you compile
will have COFF commentary in it, even if you don't explicitly
put some in.

But, worse, some of the major libraries, such as libc.a, libcurses.a,
libX11.a (et al), have massive amounts of commentary.  This stuff
adds up.  In some cases, I found that nearly *50,000* bytes of
COFF commentary were present in some of these libraries, and that
(especially with X11 and curses) most of this will also end up
in *your* program if you don't take steps to prevent this.

Check your libraries and binaries for the amount of COFF commentary:
	mcs -p XXX | wc -c

Next, some suggestions:

1)	Get rid of the commentary in the "standard" libraries.
	It just wastes space on your disk, and unless you are
	beta testing a new development system, it suffices to
	know that you loaded against Dev. Sys. 1.0 (or whatever).
	For each library you want to shrink, do this:
		mcs -d libXXX.a
		ar ts libXXX.a

2)	Get rid of the boilerplate commentary in your object files.
	You have (at least) three options (XXX is a final binary,
	XXX.o is a component object file, $(MCS)=mcs in this discussion):

	2a)	Get rid of it all, including your own commentary.
		Run this command (from your makefile!):
			$(CC) $(OBJS) -o XXX
			$(MCS) -d XXX

	2b)	Get rid of commentary from #ident lines in standard
		headers, but retain your own #ident comentary:
			Edit each standard header (yecch!)
			Comment out or delete #ident lines

	2c)	Get rid of commentary from all #ident lines, but
		add your own new commentary using "mcs".  To do
		this conveniently, it is easiest to change the
		".c.o" (and similar) rules in your makefile:
				$(CC) $(CFLAGS) -c $*.c
				$(MCS) -d -a "`stamp $*.c`" $*.o
		"stamp" is a little program we use which prints
		"@(#)" followed by the *external* release number
		(which usually has no correspondence to SCCS or
		RCS rev numbers) followed by the internal rev #
		of the source file and date of the source file).
		We also add a comment to the final binary:
			$(CC) $(OBJS) -o XXX
			$(MCS) -a "$(COPYRIGHT)" XXX

Finally, the (Usenet) obligatory complaint or showing of ignorance:

There should be two options to cpp to control #ident lines:
	a)	Ignore *all* #ident lines
	b)	Ignore #ident lines in header files included
		with the <header.h> syntax.

This latter option would be most useful, since it allows you
to not include #ident lines from "standard" (e.g. stable)
software, while retaining the automatic #ident lines which
RCS or SCCS generates for your software.


Rick Richardson | Looking for FAX software for UNIX/386 ??? Ask About: |Mention
PC Research,Inc.| FaxiX - UNIX Facsimile System (tm)                   |FAX# for
uunet!pcrat!rick| FaxJet - HP LJ PCL to FAX (Send WP,Word,Pagemaker...)|Sample
(201) 389-8963  | JetRoff - troff postprocessor for HP LaserJet and FAX|Output

More information about the Comp.unix.i386 mailing list