🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51919

Re: destructors for globals not getting called

#51919
From: Joe Buck
Date: Tue, 09 Mar 1993 19:50
45 lines
2206 bytes
In article <1993Mar8.233134.2872@dres.dnd.ca> krussell@dres.dnd.ca writes:
>In article <1993Mar8.191354.24920@csi.jpl.nasa.gov>,
>           mwette@csi.jpl.nasa.gov (Matt Wette) writes:
>|> I'm using
>|> 	gcc-2.3.3
>|> 	binutils-2.0/ld
>|> 	gas-1.38.1
>|> 
>|> It seems that the destructors for globals (i.e., non-automatic)
>|> objects are not getting called.  (The libg++/test-install fails!)
>
>I think I had the same problem with the destructors (on a
>sun4-sunos4.1.1) and I resolved it by not using "binutils-2.0/ld".
>However, it seems that "binutils-2.1/ld" fixes the problem.

The problem is this: the __do_global_dtors() function has the following
code to call destructors:

  unsigned nptrs = (unsigned) __DTOR_LIST__[0];
  unsigned i;

  /* Some systems place the number of pointers
     in the first word of the table.
     On other systems, that word is -1.
     In all cases, the table is null-terminated.  */

  /* If the length is not recorded, count up to the null.  */
  if (nptrs == -1)
    for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);

  /* GNU LD format.  */
  for (i = nptrs; i >= 1; i--)
    __DTOR_LIST__[i] ();

The problem is that the Gnu linker used to fill in the length of the list
of destructors correctly; nptrs was being set to zero in the above.  I'd
worked around the problem by commenting out the "if (nptrs == -1)" so that
the list would be counted.  I'm glad to hear that binutils-2.1 fixes the
problem.




--
Joe Buck	jbuck@ohm.berkeley.edu
Technical Details
Message-ID: <1nisf0$cmk@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!newsserver.jvnc.net!howland.reston.ans.net!agate!forney.berkeley.edu!jbuck
References: <1993Mar8.191354.24920@csi.jpl.nasa.gov> <1993Mar8.233134.2872@dres.dnd.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6d54eead721d2f19
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-03-09 11:59:15 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!newsserver.jvnc.net!howland.reston.ans.net!agate!forney.berkeley.edu!jbuck
From: jbuck@forney.berkeley.edu (Joe Buck)
Newsgroups: gnu.gcc.help
Subject: Re: destructors for globals not getting called
Date: 9 Mar 1993 19:50:56 GMT
Organization: U. C. Berkeley
Lines: 45
Message-ID: <1nisf0$cmk@agate.berkeley.edu>
References: <1993Mar8.191354.24920@csi.jpl.nasa.gov> <1993Mar8.233134.2872@dres.dnd.ca>
NNTP-Posting-Host: forney.berkeley.edu