delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/15/12:05:21

Xref: news2.mv.net comp.os.msdos.djgpp:5719
From: Gavin Smyth <sgs1 AT scigen DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Executable size
Date: Mon, 08 Jul 1996 07:39:29 -0700
Organization: The Generics Group Ltd
Lines: 110
Message-ID: <31E11DA1.5E06@scigen.co.uk>
References: <4rpd3d$l3u AT solaris DOT cc DOT vt DOT edu>
NNTP-Posting-Host: sgs_pc.generics.co.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

There have been a number of people noting that DJGPP executables are
quite large. Some other folks have pointed out Laszlo Molnar's DJP
utility to compress the executables (at the cost of possibly a little
extra startup time). Being lazy, I'd prefer not to have to remember to
augment all my make files with extra calls to DJP, so I tried hacking
the lib/specs file to add an extra call to DJP after STUBIFY
(incidentally, it'd be nice if these two programs were combined, to
save a little build time, but that's a job for someone else!).

Unfortunately, I couldn't find a description of the contents of this
file, and guesswork alone wasn't enough to do that I wanted - I
could not get the name of the final executable passed to DJP, and the
best I could do was the name given in the "-o" option to the compiler,
which could be the .exe or the COFF file which is STUBIFYed. I then
hacked the DJP source a bit, plagiarising similar code in STUBIFY
to process command line arguments, so that it could cope with the
file name I passed to it. To be consistent with STUBIFY, I also made
the echoing of progress, etc. conditional on "-v" (sorry Laszlo, your
copyright statement only appears when requested now!). Basically,
my hacked DJP takes any old file name(s), throws away any suffix, and
appends .exe, which is what the rest of the program needs to work on.

It all seems to work for me, and although compile times are a bit longer,
the saving in filespace is well worth it. If you want to try it, the
stuff below "----- SNIP HERE -----" is the patch necessary (to the
DJP source file and lib/specs).

Brief instructions:

1) Save the stuff below SNIP HERE to *two* files, one for each of
   the files to change: patch.djp and patch.spc (separate the stuff
   at the *** lines.
2) Make sure DJP is unzipped within your DJGPP tree
3) CD to the root of your DJGPP tree
4) Run "patch < patch.djp" - this alters the DJP source file.
5) Build DJP
6) Run "patch < patch.spc" (or simple edit lib/specs, and add the
   extra line (without the leading "> ") just after the invocation
   of STUBIFY.

Now, linking will automatically run DJP, and giving gcc the "-v" option
tells you what is going on.

Best of luck, and I offer no guarantees :-o

Gavin

----- SNIP HERE ------------
*** src/djp/djp.c
16a17,18
> static verbose = 0;
> 
36,37c38,42
<     printf ("Packing section %s...",sn);
<     fflush (stdout);
---
>     if (verbose)
>     {
>         printf ("Packing section %s...",sn);
>         fflush (stdout);
>     }
42c47,48
<     printf ("Done. %7d -> %7d\n",size,packedsize);
---
>     if (verbose)
>         printf ("Done. %7d -> %7d\n",size,packedsize);
61c67,68
<     printf ("\nPacking %s\n",program);
---
>     if (verbose)
>         printf ("\nPacking %s\n",program);
147,148c154,161
<     printf ("\nDJP 1.02 executable file compressor for DJGPP V2 
programs.\n"
<             "(C) 1996 ML1050\n");
---
>     if (argc > 1 && strcmp(argv[1], "-v")==0)
>     {
>         verbose = 1;
>         printf ("\nDJP 1.02 executable file compressor for DJGPP V2 programs.\n"
>                 "(C) 1996 ML1050\n");
>         argv++;
>         argc--;
>     }
151c164
<         printf ("Usage: %s exefile [exefiles]\n",argv[0]);
---
>         printf ("Usage: %s [-v] exefile [exefiles]\n",argv[0]);155c168,182
<         if (v2packimage(argv[argc]))
---
>     {
>         char tmpname[ 200 ];
>         char *p, *suffpos = 0;
>         strcpy (tmpname,argv[argc]);
>         for (p=tmpname; *p; p++)
>         {
>             if (strchr("/\\:", *p))
>                 suffpos = 0;
>             else if (*p == '.' )
>                 suffpos = p;
>         }
>         if (!suffpos)
>             suffpos = tmpname + strlen(tmpname);
>         strcpy (suffpos,".exe");
>         if (v2packimage(tmpname))
158a186
>     }
*** lib/specs
28a29
> %{!c:%{!M:%{!MM:%{!E:%{!S:djp %{v} %{o*:%*} %{!o*:a.exe}}}}}}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019