Xref: utzoo comp.unix.i386:5515 comp.lang.c:29279 comp.windows.x:22623 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!uunet!pcrat!rick From: rick@pcrat.uucp (Rick Richardson) Newsgroups: comp.unix.i386,comp.lang.c,comp.windows.x Subject: Tip Concerning Massive COFF Comment Sections Keywords: COFF mcs X Message-ID: <1990Jun1.134459.4296@pcrat.uucp> Date: 1 Jun 90 13:44:59 GMT Organization: PC Research, Inc. Lines: 93 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 file. Now, some reality: ------------------ Nearly all of the common include files, such as 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: .c.o: $(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 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 -- 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