gcc iussue or ... ?

John Polstra jdp at polstra.com
Sat Apr 12 11:41:20 PDT 2003

In article < at>,
Gianmarco Giovannelli  <gmarco at scotty.masternet.it> wrote:
> In FreeBSD 4.8, gcc version 2.95.4 20020320 [FreeBSD] :
> nm -r --size-sort globals.o
> 01061860 D wp_version
> 01061800 D w_anim
> 01061788 D cwrap
> 01061720 D PacketSender
> 002190a0 D PacketFetcher
> 002180a0 D buffer
> 00111020 D region
> 000138a0 D location
> 00009b80 D spawnsp
> 00009b80 D ownsp
> 00009b80 D itemsp
> 00009b80 D glowsp
> 00009b80 D cspawnsp
> 00009b80 D cownsp
> 00009b80 D contsp
> 00009b80 D charsp
> 00008520 D menupriv_
> 00006114 T strlwr
> 00006114 t gcc2_compiled.
> [...]
> In linux Debian 3.0, gcc 2.95.4 20011002 (Debian prerelease)
> nm -r --size-sort globals.o
> 0105c520 B wp_version
> 0105c4f0 B clConsole
> 0105c4c0 B w_anim
> 0105c4a0 B iwrap
> 0105c468 B cmultisp
> 0105c420 B PacketSender
> 002190a0 B PacketFetcher
> 002180a0 B buffer
> 00111020 B region
> 000138a0 B location
> 00009b80 B spawnsp
> 00009b80 B ownsp
> 00009b80 B itemsp
> 00009b80 B glowsp
> 00009b80 B cspawnsp
> 00009b80 B cownsp
> 00009b80 B contsp
> 00009b80 B charsp
> 00008520 B menupriv_
> So the point is why Linux/mingw have a lot of things in bss while 4.8 (with 
> the same gcc of linux debian 3.0 and 5.0 with the same gcc 3.2.1 of mingw) 
> put them in Data ?

Maybe Linux is using the "-fconserve-space" g++ option.  From the
info pages:

     Put uninitialized or runtime-initialized global variables into the
     common segment, as C does.  This saves space in the executable at
     the cost of not diagnosing duplicate definitions.  If you compile
     with this flag and your program mysteriously crashes after
     `main()' has completed, you may have an object that is being
     destroyed twice because two definitions were merged.

     This option is no longer useful on most targets, now that support
     has been added for putting variables into BSS without making them

That last paragraph suggests that maybe FreeBSD's compiler is
configured slightly wrong, such that it does not do what the
paragraph says.  In any case, try adding this option to your
compiles on FreeBSD and see if it helps.

  John Polstra
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa

More information about the freebsd-hackers mailing list