gcc iussue or ... ?

Leo Bicknell bicknell at ufp.org
Fri Apr 11 07:07:40 PDT 2003


In a message written on Fri, Apr 11, 2003 at 08:41:37AM +0200, Gianmarco Giovannelli wrote:
> The problem is that if I compile it under FreeBSD it is a binary of 19M, 
> while on linux (debian 3.0), same Makefile, is only 2MB. FreeBSD 5.0 and 
> OpenBSD 3.1 produce the (about) 19M file.

Well, the problem location is fairly obvious:

% ls -lags | sort -nr | more
19416 -rwxr-xr-x  1 bicknell  wheel  19854956 Apr 11 09:49 lonewolf*
16912 -rw-r--r--  1 bicknell  wheel  17286792 Apr 11 09:42 globals.o
  368 -rw-r--r--  1 bicknell  wheel    365140 Apr 11 09:46 npcinfo.o
  304 -rw-r--r--  1 bicknell  wheel    301100 Apr 11 09:47 targeting.o
  272 -rw-r--r--  1 bicknell  wheel    267648 Apr 11 09:48 virtues.o
[etc]

A quick nm --size-sort globals.o | tail shows:

00009b80 D ownsp
00009b80 D spawnsp
000138a0 D location
00111020 D region
002180a0 D buffer
002190a0 D PacketFetcher
01061710 D PacketSender
01061778 D cwrap
010617f0 D w_anim
01061850 D wp_version

buffer, for instance appears to be 129 * 17000 = 2193000, a 2M
buffer, and nm shows 2195616 bytes.

I can't track down quickly why the others are so big, but I suspect you
may be making them bigger than you expected.  It could also be that
FreeBSD puts some types of globals in the executable to load, where as
Linux puts them in some zero filled pages or something, I don't know
enough to know for sure.  Either way, you probably want to make the
data smaller, or dynamically allocate it to make sure you don't run
into this on any platform.

-- 
       Leo Bicknell - bicknell at ufp.org - CCIE 3440
        PGP keys at http://www.ufp.org/~bicknell/
Read TMBG List - tmbg-list-request at tmbg.org, www.tmbg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030411/9c3cefa8/attachment.bin


More information about the freebsd-hackers mailing list