🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #838

static constructors and libraries

#838
From: Bradley D. Keister
Date: Thu, 20 Aug 1992 05:43
45 lines
1847 bytes
The following output of 'nm' may shed some light on a problem I've had
with static constructors inside libraries which I posted earlier.  The
class "dummy_class" has a constructor which computes 
pi = 4 * arctan(1), and "dummy_initialize" is a static object of type
"dummy_class".  Any source module which uses pi includes a header
file containing the line

extern dummy_class dummy_initialize

----------------

dummy.o (g++/Sun):
00000040 T __GLOBAL_$I$dummy_initialize
00000000 T ___14dummy_class
         U _atan
00000060 D _dummy_initialize
00000008 C _pi
00000000 t gcc2_compiled.

dummy.o (g++/DECstation):
00000000 N $L1
00000000 N $L2
00000000 N $L3
00000064 T _GLOBAL_$I$dummy_initialize
00000000 T __14dummy_class
         U atan
00000000 N gcc2_compiled.
000000a0 G dummy_initialize
00000008 C pi

If dummy.o is linked directly to other modules, then the constructor
is called at run time and pi gets its correct value.  If dummy.o is
instead linked in from a library, then the DEC executable calls the
constructor, but the Sun executable does not, leaving pi=0.  Is
"dummy_initialize" for the Sun being put in the wrong segment?

Brad Keister
Department of Physics
Carnegie Mellon University
Pittsburgh, PA 15213
(412) 268-2772 (office)
(412) 681-0648 (FAX)

internet:	keister@poincare.phys.cmu.edu
BITNET:		keister%poincare.phys.cmu.edu@CARNEGIE
Technical Details
Message-ID: <9208201343.AA02450@poincare.phys.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister
From: keister@poincare.phys.cmu.edu (Bradley D. Keister)
Subject: static constructors and libraries
Message-ID: <9208201343.AA02450@poincare.phys.cmu.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 20 Aug 1992 05:43:47 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 46